Hey, guy I'm having some trouble with my function see below:
bool tryAgain()
{
char answer;
cout << "Do you want to enter another number? (Y/N): ";
cin >> answer;
answer = toupper(answer);
while(answer != 'Y' || answer != 'N')
{
cin.clear();
cin.ignore(10, '\n');
cout << "Input invalid." << endl;
cout << "Do you want to enter another number? (Y/N): ";
cin >> answer;
answer = toupper(answer);
}
if(answer == 'Y')
{
return true;
}
else
{
return false;
}
}
the function enters the while loop even when a correct answer is inputted from the get go & if I do enter the while loop I get stuck even though I enter a correct answer. To me this logic makes sense, break the loop when the input is == 'Y' || 'N', but its keeps looping. Help me see my logical error! Thanks for your help.