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?


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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include <iostream>
using namespace 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!";
			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 ||

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


Note use of != and &&
1
2
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.