Hi all, i have this average grade code.
My input is only Letter (A/B/C/D/F), is it possible that anyone can help me input lines that shows error message if the user input other letter beside the a/b/c/d/f ?
#include <iostream>
#include <ctype.h>
#include <string>
usingnamespace std;
int main() {
//initialize to null to the while loop will run
char ans = '\0';
//make a condition that accepts a to f then reverse the it
//using ! operator
while( !((ans>='a' && ans<='d') || ans=='f') ) {
cout << "Enter grade: ";
cin >> ans;
//make the input lower case so the condition will accept uppercase input
ans = tolower(ans);
}
return 0;
}