Having an issue when user types more than one letter in my do while loop.
It repeats "Would you like to make another calculation? (Y/N): " multiple times.
How do I limit this? I have tried setw() but that didn't seem to change anything.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
char response;
do{
//CODE HERE
cout << "Would you like to make another calculation? (Y/N): ";
cin >> response
do{
if(toupper(response)!= 'Y' && toupper(response) != 'N'){
cout << "Please enter 'Y' or 'N'." << endl;
cout << "Would you like to make another calculation? (Y/N): ";
cin >> response;}
}while(toupper(response) != 'Y' && toupper(response) != 'N');
}while(toupper(response) == 'Y');
I posted this already on a different thread where you pointed someone to a goto tutorial, but everything I've been taught recommends against using goto statements.