The lab focuses on testing characters. I am supposed to enter a character and it will read if it is a capital letter it lowercase letter or another type. My if statements are correct. My statements which prompt for and read what I put in are okay, too. The problem is that when I enter q or Q which should make the program end, the program still reads the q or Q that I entered. Shouldn't the program end and not read those letters once I enter it?
int main()
{
char input = ' ';
//set up loop such that all tasks below is done as long as input
// is not a q or a Q (that is, quit)
while (toupper(input) != 'Q' || tolower(input) != 'q')
{
cout << "Enter any character: ";
cin.get(input);
cin.ignore();
cout << "The character you entered is: " << input << endl;
if (isalpha(input))
cout << "That's an alphabetic character.\n";
if (isdigit(input))
cout << "That's a numeric digit.\n";
if (islower(input))
cout << "The letter you entered is lowercase.\n";
if (isupper(input))
cout << "The letter you entered is uppercase.\n";
if (isspace(input))
cout << "That's a whitespace character.\n";
//add code to test for alphanumeric
if (isalnum(input))
cout << "The character you entered is alphanumeric.\n";
//add code for a punctuation
if (ispunct(input))
cout << "The character you entered is a punctuation.\n";
}
system("PAUSE");
return 0;
}