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?
#include <iostream>
usingnamespace std;
int main()
{
char choice, again;
double height, weight;
//Display the menu
do
{
cout <<"\t\tFind Your Ideal Weight!\n\n"<<endl;
cout <<"A. Enter Female Date\nB. Enter Male Data\nC. Quit"<<endl;
cout <<"Enter Your Choice: ";
cin >>choice;
//validate the choice
while (choice=='A'||choice!='B'||choice!='C'||choice!='a'||choice!='b'||choice!='c')
{
cout <<"You entered '"<<choice<<"' which is not valid\n";
cout <<"Enter a valid choice! ";
cin >>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!";
elseif (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!";
elseif (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!";
elseif (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!";
elseif (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;
}