It would probably be easier to use switch/case in this situation. How about something like this?
Code:#include <iostream> #include <string> #include <cctype> using namespace std; int main () { string s; do { cout << "What would you like today?" << endl; cin >> s; switch(toupper(s[0])){ case 'W': cout << "What is the amount?" << endl; //etc break; case 'Q': cout << "Goodbye"; return 0; default: cout << "Invalid selection. Please try again." << endl; break; }; } while(cin); return 0; }




Reply With Quote