I am making a program (too much freetime) about cramer's rule and matrices. And somewhere, I have this problem where you will need to input "Yes" or "No". And If I typed other words (lol for example) it would not go to else if statement or ask the question again. How do I limit the answers to only Yes / No?
cout << "There! you have now your first equation! is it " << a << "x+" << b << "y=" << e << "? Is it? Yes/No"<<endl;
cin >> z;
if ( z== "No" )
{
while ( z== "No" )
{
cout << "what is the value of x?"<<endl;
cin >> a;
cout << "\n"<<endl;
cout << "what is the value of y?"<<endl;
cin >> b;
cout << "\n"<<endl;
cout << "what is the value of answer?"<<endl;
cin >> e;
cout << "\n"<<endl;
cout << "There! you have corrected your first equation! is it " << a << "x+" << b << "y=" << e << "? Is it? Yes/No"<<endl;
cin >> z;
}
}
else if ( z== "Yes" )
{
cout << "We will now proceed!"<<endl;
}
I am just a beginner in c++ using codeblocks
Aucun commentaire:
Enregistrer un commentaire