I have a project do for a class tomarrow and i cant get it to work correctly. I need to create do/while loops that will check to make sure the input is legal. (ex: "choose A, B, or C" and if you put G its ask you again.) Can anybody help me?
#include <iostream>
using namespace std;
int main ()
{
char ans;
ans = 'y';
while (ans == 'y' || ans == 'Y')
{
cout << "Would you like to price anthoer car? (y,n)" << endl;
cin >> ans; //if ans == y loop back to top
//if ans == n
}
cout << "Thank you for using this priceing tool. Goodbye." << endl;