Well, since my program is so short, I'm just going to put it all here.
I am sure that there is something that I'm not understanding here.
When I run this particular program, I'm wanting it to take a character that is input by the user, and return a number by calling the threatmult function. However when I run the program it simply gets stuck in the while loop in the main function. I am missing something simple here, and I know it. So I'm basically asking for someone to spell out what I'm doing wrong in simple terms, because I'm just not understanding it. Also, if there's a better way to do the things that I'm trying to do, please let me know. If someone feels really kind today, they also might want to consider helping me know about error detection. I'm trying to make sure they can enter in upper or lower case letters : 'h' 'l' and 'n'. Oh, and I can't seem to get a new line after the
cin >> threatentry ;
Well, thanks in advance!
Code:
#include <iostream.h>
double threatmult(char threat)
{
double multiplier;
if (threat == 'H')
multiplier = 1;
else if (threat == 'h')
multiplier = 1;
else if (threat == 'L')
multiplier = .5;
else if (threat == 'l')
multiplier = .5;
else
multiplier = .33333;
return (multiplier);
}
int main()
{
char threatentry;
cout << "Please enter a valid threat level." << endl;
cout << "Valid entries are the following letters (upper or lower case): " ;
cout << "H,L,N" << endl;
cin >> threatentry ;
cout << "You entered : " << threatentry ;
while (threatentry != (('H' || 'h') || ('L' || 'l') || ('N' || 'n')))
{
cout << "Invalid entry, enter either H, L, or N." << endl;
cin >> threatentry ;
}
return 0;
}