Exercise:
Write a C++ program using do-while loop that prompts for and inputs a user entry of "Y" or "N". f the user fails to enter a correct value, the loop outputs an error message and then repeats the request for the user to enter a value.
This is what I did and it seems like I did the other way around. (NO BOOLEANS, NO GETLINES). Just Do-While Statement
#include <iostream>
using namespace std;
int main()
{
char ans = ' ';
string ques = "Are you 18 years old or above? ";
do
{
cout<<ques;
cin>>ans;
if (ans == 'y'|| ans == 'Y'|| ans == 'N' || ans == 'n')
{
cout<<"VALID LETTER"<<endl;
}
else
{
cout<<"INVALID LETTER"<<endl;
}
}while (ans == 'y'|| ans == 'Y' || ans == 'N' || ans == 'n');
system("pause");
}