I'm having problems checking for similar string input from the user and i'm pretty sure i'm not getting my concepts wrong. I'm afraid i might be missing out something.
I'm trying to ensure that the user input only grade A-F therefore i tried doing the input check like shown below but it doesn't seem to be working correctly.
string grade;
bool input=false;
while (!input)
{
cout << "Please enter grade : ";
getline(cin, grade);
if (grade == "Grade A" || grade == "Grade B" || grade == "Grade C" || grade == "Grade D" || grade == "Grade E" || grade == "Grade F")
{
input = true;
cout << "Successful input " << endl;
}
else
{
cout << "Please enter the correct input" << endl << endl;
input = false;
}
}
For example if i type Grade A, it's suppose to return successful input while exiting out of the loop however it doesn't seem to work. I'm currently using Visual Studio 2015 to program this application.