![]() You know, I believe my boss is completely correct (at least on this one particular point). He said that if I send four or five emails to a person within a four- or five-minute period, I should probably have picked up the phone and made a telephone call-it would have taken less time, and been more efficient. ![]() Hey, Scripting Guy! I was talking to my boss the other day, and he made a rather interesting observation. What I want is it will keep me prompting an mount either less than or equal to my current balance so that it will not display a negative new balance.Summary: Microsoft Scripting Guy, Ed Wilson, shows how to use Windows PowerShell to data mine your Microsoft Outlook Inbox. It will tell me that I have -1 as my New balance which should't be. It will tell me at first that I have insufficient funds and would prompt me to enter another amount. My current balance is 500 and I withdraw 501. I have quoted your original post because it includes the full code and your original post where you gave some good example values. Ok, well lets take a quick look at your original code. Following you code manually is almost always a good way to find bugs like that. Take special notice of what will happen when the user enters a bad value the second time. If you can't figure out what was wrong with your original code, follow the code line by line manually. I personally never use goto in C because it can make your code look sloppy and hard to follow. That is essentially what I suggested, except with a goto statement instead of recursion. Printf("\nDo you want to continue-Yes -No:") Printf("\nYour have entered the wrong code.\n") Printf("-Deposit\n-Withdraw\n-Account Balance\n\n") ![]() Printf("\nYour Current Balance is:%d\n\n",cb) Printf("\nYou do not have any money moron.\n") Printf("\nYour New Balance is :%d\n",cb) Printf("\nYou have succesfully withdraw") Printf("\nPlease Enter another Amount.\n") Printf("\nSorry!You have Entered an Insufficient amount!\n") Printf ("\nYour previous balance is %d\n", cb-d) Printf("\nYou have successfully deposit to your account!!!") Printf("\nPlease enter amount to be deposited:") Printf("\nYour current balance is %d\n",cb) Yeah, it is one of the exercises given.I have my solution to code below but still trying to figure out the problem with the code above.Here is my complete code to the working one: #include If you have learned recursion before, use it, professors love students that use recursion. If this is not homework, then I recommend recursion, as that is the cleanest way to do it. If that is the case, think about something like a while loop, a for loop could also work, but the syntax would look a little silly. However, if your teacher/professor does not allow you to use concepts that you haven't learned yet, you may need to look for an alternate answer. You may not have learned recursion yet in your class, its very useful. I'm assuming this is a homework assignment. You see, in my example, if you try to withdraw too much, then it goes back to the beginning of the withdraw() function. Printf ("\n-THANK YOU FOR BANKING WITH US-\n\n") Printf ("\ndo you want to continue? Press -for yes for no:") Printf("***PLEASE ENTER A VALID TRANSACTION***\n\n") Printf ("\n\namount withdraw: %d",wdraw) Printf ("please be reminded that your current balance is: %d\n",ab) Printf ("\n\nAmount withdraw: %d",wdraw) Printf ("\n\nplease be reminded that your current balance is: %d\n", ab) Printf ("\n\nYour Current Balance is: %d\n\n",ab) What I want is it will keep me prompting an mount either less than or equal to my current balance so that it will not display a negative new balance. This is already running however, I do have a little problem with the WITHDRAWAL part.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |