mercredi 27 octobre 2021

Terminating program if the right input is inserted

So my problem is, I want to terminate the program if the right input was inserted, like A-E(big or smallcaps) and I want to ask them again the question if they input wrong letters like k,x,L. But my problem is, it wont stop asking even if the right letter is inputted.

#include <iostream>
#include <string>
using namespace std;
int main()
{
char letter;
char grades;
char A, B, C, D, E;
letter = A, B, C, D, E;
do{
cout << "\n Input grade letter: ";
cin >> letter;
if (letter=='A' || letter=='a')
{
    cout << "Your grade is in the range of 96-100";
}else if (letter=='B' || letter=='b')
{
    cout << "Your grade is in the range of 91-95";
}
else if (letter=='C' || letter=='c')
{
    cout << "Your grade is in the range of 86-90";
}
else if (letter=='D'|| letter=='d')
{
    cout << "Your grade is in the range of 80-85";
}
else if (letter=='E'|| letter=='e')
{
    cout << "Your grade is in the range of 79 and below";
}
else {
    cout << "Invalid Input! Try again!";
}
}while(letter==A, B, C, D, E);
///if the input correct
cout<< "\nBye";

return 0;

}

Aucun commentaire:

Enregistrer un commentaire