I'm taking a beginners course in C++. Our latest project is to create this program that sort of outputs a phone company bill based on a few user inputs.
The problem I *think* I am having is that my first if statement follows through regardless if the char character is correct or not.
Early in the program I have the user input a character for "servcode":
1 2 3 4 5 6 7 8 9
cout << "Please enter your account number: ";
cin >> acctnum;
cout << endl
<< "Service codes: \n"
<< "R = Regular Service\n"
<< "P = Premium Service\n"
<< endl
<< "Please enter your service code: ";
cin >> servcode;
The user inputs either R, r, P, or p.
I then have an If and Else If statement that checks the value of that char: if (servcode == 'r', 'R') //Regular Service
and
elseif (servcode == 'p', 'P') //Premium Service
Unfortunately the program always follows the if branch no matter what the char the user inputs is.
Here is the full code: http://pastebin.com/hHQe26HQ
(sorry, pastebin kind of pushes some things down to a new line making it slightly harder to read).
So am I simply not able to check if a char is equals or am I doing something else wrong?
Originally I thought it didn't work but that turned out to be an issue with my compiler and it's now resolved. Here is the finished code (although I'm still going to mess with it, but it's working):