### Simple weight checking program bugged?

Below I have my code for the weight checking program I'm building for my class. It reads your height, weight and tells you if you are at the ideal weight. (Side Note: Don't get me started on what this assignment considers ideal.....). The issue is that when it is run, it sees every input as invalid. If you choice 'A' it tells you it is invalid and asks for another selection for instance. I have it set to make sure A, a, B, b, C, or c are inputed. Any suggestions?

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113`` ``````#include using namespace std; int main() { char choice, again; double height, weight; //Display the menu do { cout <<"\t\tFind Your Ideal Weight!\n\n"<>choice; //validate the choice while (choice=='A'||choice!='B'||choice!='C'||choice!='a'||choice!='b'||choice!='c') { cout <<"You entered '"<>choice; } //Process the users choice if (choice!='c'||choice!='C') { cout <<"Enter your height (inches): "; cin >>height; cout <<"Enter your weight (lbs.): "; cin >>weight; //Validates height and weight if (choice=='A'||choice=='a') { while (height<58||height>71) { cout <<"ERROR! Please enter a height of at least 58 inches and not more then 71 inches: "; cin >>height; } while (weight<100) { cout <<"ERROR! Please enter a weight of at least 100 lbs.: "; cin >>weight; } } else { while (height<61||height>75) { cout <<"ERROR! Please enter a height of at least 61 inches and not more then 75 inches: "; cin >>height; } while (weight<123) { cout <<"ERROR! Please enter a weight of at least 123 lbs.: "; cin >>weight; } } } if (choice=='a'||choice=='A') { if (height>=58&&height<=64) { if (weight>=100&&weight<=114) cout <<"Your weight is below the target weight. Get to 115 lbs. to be in the target zone!"; else if (weight>=115&&weight<=133) cout <<"Your weight is in the target zone! Great job!"; else cout <<"Your weight is above the target weight. Get to 133 lbs. to be in the target zone!"; } else { if (weight>=117&&weight<=135) cout <<"Your weight is below the target weight. Get to 136 lbs. to be in the target zone!"; else if (weight>=136&&weight<=156) cout <<"Your weight is in the target zone! Great job!"; else cout <<"Your weight is above the target weight. Get to 156 lbs. to be in the target zone!"; } } else { if (height>=61&&height<=67) { if (weight>=123&&weight<=133) cout <<"Your weight is below the target weight. Get to 134 lbs. to be in the target zone!"; else if (weight>=134&&weight<=150) cout <<"Your weight is in the target zone! Great job!"; else cout <<"Your weight is above the target zone. Get to 150 lbs. to be in the target zone!"; } else { if (weight>=137&&weight<=155) cout <<"Your weight is below the target zone. Get to 156 lbs. to be in the target weight!"; else if (weight>=156&&weight<=175) cout <<"Your weight is in the target zone! Good job!"; else cout <<"Your weight is above the target zone. Get to 175 lbs. to be in the target zone!"; } } cout <<"Restart for another person? (Y/N): "; cin >>again; while (again!='y'||again!='Y'||again!='n'||again!='N') { cout <<"Enter 'Y' for Yes, or 'N' for No: "; cin >>again; } } while (again=='y'||again=='Y'); system("pause"); return 0; }``````

Note use of `==` and `||`

 ``12`` ``````if (choice=='A'||choice=='B'||choice=='C'||choice=='a'||choice=='b'||choice=='c') cout << "good choice";``````

Note use of `!=` and `&&`
 ``12`` ``````if (choice!='A'&&choice!='B'&&choice!='C'&&choice!='a'&&choice!='b'&&choice!='c') cout << "incorrect choice";``````

I understand! I was reading it like a human and not a machine :P
Topic archived. No new replies allowed.