I am trying to write a program, and I am using classes when doing it. My problem right now is I am using a class, and have gotten it setup to ask a question and take in a char. I was trying to use the toupper command to make the char uppercase. For some reason, it is not changing the character to uppercase. Please check out my code and see if you can tell what I am doing wrong. I am using the #include <cctype> header to get the toupper, but it is not changing it to uppercase. Please assist!
void bill::aBills()
{
// Add Bills to the application.
system("cls");
cout << "This is the Add Bills screen.\n";
char choice;
do // Runs question until a correct response is made.
{
cout << "\n\nPlease select a category that matches the bill: "
<< "Medical (M), House (H), Credit (C): ";
cin >> choice;
//toupper(choice);
switch(toupper(choice)) // Gives user a choice of the categories to choose from.
{
case'M': bCategory = "Medical";
break;
case'H': bCategory = "House";
break;
case'C': bCategory = "Credit";
break;
default : cout << "Incorrect Selection, please try again!\n\n";
system("pause");
break;
}
}while ((choice != 'M') || (choice != 'H') || (choice != 'C'));
setCategory(bCategory);
system("pause");
}
it made it so that the character changed to uppercase into the switch, but when it ran through the while loop, it only sees it as its lowercase form. Please help.
Thanks, that fixed that issue, but can you tell me if my do... while loop is incorrect? When I run the program, and the answer is one of the answers in the while loop, it still repeats the loop, and does not break it. Is there something that I have done wrong on it?
Thanks!! I don't know what I was thinking. My logic was wrong when it came to this. It took me a few minutes of putting the statements together, and turning them into the logic statements to determine what I was doing wrong. Thanks for the help!! Sometimes its the most simplest of answers that cause the biggest issues.