I have a simple program showm below that asks the user for a choice of drink. But if they enter a value that is incorrect, how can you restart the program? Do I use a do...while?
Thanks
Code:#include <iostream> using namespace std; int main() { int choice; cout << " Please enter a choice of drink (1-3): \n"; cin >> choice; switch (choice) { case 1: cout <<"Cola"; break; case 2: cout <<"Orange"; break; case 3: cout <<"Water"; break; default: cout <<"Error. choice was not valid, here is your money back"; } system("Pause"); return 0; }




Reply With Quote