char function problem
I can't figure out what I have wrong here. It always says invalid choice.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
char menu ()
{
char userChoice;
cout<<"Surface Area Calculator";
cout<<"\n\nS) Sphere";
cout<<"\nC) Cone";
cout<<"\n\nQ) Quit";
cout<<"\n\nEnter your choice: ";
cin>>userChoice;
cout<<endl;
userChoice = toupper (userChoice);
while (userChoice != 'S' or userChoice != 'C' or userChoice != 'Q')
{
userChoice = toupper (userChoice);
cout<<userChoice<<" is an invalid choice. Try again: ";
cin>>userChoice;
}
return userChoice;
}
|
They should be and not or. Also, generally we use && for logical and and || for logical or instead of and/or.
wow stupid mistake been trying to figure that out for hours. Thanks so much!!
Topic archived. No new replies allowed.