| | |
Not sure why [continue] is not working
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2007
Posts: 12
Reputation:
Solved Threads: 0
I tried getting rid of a loop and did this:
There is still something wrong and I cant figure it out. Could someone give me some insight?
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <string> using namespace std; int main() { double withdraw, deposit, balance, newBalance, amount; char ans; string choice; balance = 1000; cout << "Welcome to Whatever ATM!" << endl; do { cout << "\nWhat would you like to do from the following?\n" << "\nWithdraw from account\n" << "Deposit money into account\n" << "Balance inquiry\n" << "Quit\n" << "\nPlease select now" << endl; cin >> choice; ans = choice[0]; newBalance = balance; if ((ans == 'w') || (ans == 'W')) { cout << "\nWhat amount would you like to withdraw?" << endl; cin >> amount; while (amount > balance) { cout << "Sorry, you have insufficient funds.\n" << "Please try again: "; cin >> amount; } if (amount <= balance) { balance = balance - amount; newBalance = balance; cout << "Thank you, your new balance is: " << newBalance << endl; cout << "Would you like to make another transaction? (Y/N)" << endl; cin >> ans; if ((ans == 'y') || (ans == 'Y')) continue; else break; } } else if ((ans == 'd') || (ans == 'D')) { cout << "\nWhat amount would you like to deposit?" << endl; cin >> amount; balance = balance + amount; newBalance = balance; cout << "Thank you, your new balance is: " << newBalance <<endl; cout << "Would you like to make another transaction? (Y/N)" << endl; cin >> ans; if ((ans == 'y') || (ans == 'Y')) continue; else break; } else if ((ans == 'b') || (ans == 'B')) { cout << "Your balance is: " << balance <<endl; cout << "Would you like to make another transaction? (Y/N)" << endl; cin >> ans; if ((ans == 'y') || (ans == 'Y')) continue; else break; } else if ((ans == 'q') || (ans =='q')) break; else continue; } while ((ans == 'w') || (ans == 'W') || (ans == 'd') || (ans == 'D') || (ans == 'b') || (ans == 'B') || (ans == 'q') || (ans == 'Q')); cout << "\nThank you for banking with Whatever ATM!" << endl; }
There is still something wrong and I cant figure it out. Could someone give me some insight?
So you didn't bother with my questions at all and just made a convoluted while statement? Then all you can say is "something is wrong -- go find it and tell me what to do"?
I don't think so...
I realize you're probably frustrated (so am I), but if you had followed my posts you might have learned something about how to debug your code.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
![]() |
Similar Threads
- Avoid Alienware! (semi OT) (Windows NT / 2000 / XP)
- What's better? Windows 2000 Server or Linux Server? (Windows Servers and IIS)
- nvidia geforce 5600 graphics problem (Monitors, Displays and Video Cards)
- Internet partially stops working after a few hours (Viruses, Spyware and other Nasties)
- IE Will Not Open Anymore (Viruses, Spyware and other Nasties)
- C++ menu problem (C++)
- Cannot get rid of "Cannot Find Server" message (Viruses, Spyware and other Nasties)
- HijackThis log help (Viruses, Spyware and other Nasties)
- How to Download Available Updates (Windows tips 'n' tweaks)
Other Threads in the C++ Forum
- Previous Thread: Two Player Craps
- Next Thread: Help with pascal triangle output
Views: 1193 | Replies: 12
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelper iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






