Repetition and Boolean Expressions Help Please

I need to make a program that asks for a user's gender, height, and weight and then based off their inputs, it then decides if they are accepted or not.

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
   char gender;
   bool heightOk;
   bool weightOk;
   int height;
   int weight;


    // PROCESSING - ask for the user's gender, height and weight

	do
	{
		cout << left << "Please enter the candidate's information";
		cout << "(enter 'X' to exit)\n";

		cout << "Gender: ";
		cin.get(gender);


		if (gender != 'x' && gender != 'X' && gender != 'F' && gender !=
			'f' && gender != 'm' && gender != 'M')
		{
			cout << "invalid entry" << endl;
		}

		if (gender == 'f' || gender == 'F')
		{
			cout << "height: ";
			cin >> height;
			heightOk = (height >= 62 && height <= 75);
			cout << heightOk;

			cout << "weight: ";
			cin >> weight;
			weightOk = ( weight >= 110 && weight <= 185);
			cout << weightOk;

		}
		if (gender == 'm' || 'M')
		{
			cout << "height: ";
			cin >> height;
			heightOk = (height >= 65 && height <= 80);
			cout << heightOk;

			cout << "weight: ";
			cin >> weight;
			weightOk = (weight >= 130 && weight <= 250);
			cout << weightOk;

		}
		else
		{
			cout << "please enter a valid gender";
		}



	} while (gender != 'x' && gender != 'X' && gender != 'F' && gender !=
		'f' && gender != 'm' && 'M')


    // OUTPUT - Output each grade, the GPA, and the grade point total



    return 0;
}


Everytime I enter 'm' it says invalid entry and I'm not understanding why.
You will find that entering any letter will receive the invalid entry error. You need to change your &&'s to ||'s after inputting gender.

I'd also suggest look at the if statement for males, there is something wrong there. If you need a hint, look at the if statement for females.
I changed some parts like you said but I'm still getting invalid entry.

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
do
	{
		cout << left << "Please enter the candidate's information";
		cout << "(enter 'X' to exit)\n";

		cout << "Gender: ";
		cin.get(gender);


		if (gender != 'x' || gender != 'X' || gender != 'F' || gender !=
			'f' || gender != 'm' || gender != 'M')
		{
			cout << "invalid entry" << endl;
		}

		if (gender == 'f' || gender == 'F')
		{
			cout << "height: ";
			cin >> height;
			heightOk = (height >= 62 && height <= 75);
			cout << heightOk;

			cout << "weight: ";
			cin >> weight;
			weightOk = ( weight >= 110 && weight <= 185);
			cout << weightOk;

		}
		if (gender == 'm' || gender == 'M')
		{
			cout << "height: ";
			cin >> height;
			heightOk = (height >= 65 && height <= 80);
			cout << heightOk;

			cout << "weight: ";
			cin >> weight;
			weightOk = (weight >= 130 && weight <= 250);
			cout << weightOk;

		}
		else
		{
			cout << "please enter a valid gender";
		}



	} while (gender != 'x' || gender != 'X' || gender != 'F' || gender !=
		'f'|| gender != 'm' || 'M');


    // OUTPUT - Output each grade, the GPA, and the grade point total


	return 0;
}
Sorry, I was wrong, you did need the &&'s.

I, however, ran your initial code that you pasted and it works fine, or for as much as you have done so far. Are you typing
'm'
or
m
? You need to just type m then press enter. If you're typing
'm'
you're getting the error because it's reading the quote as your character.
I'm entering just a single m. No quotes or anything. I'll give you the output I'm getting.

So I went back to the previous format I think it was just the if statement for the male that was screwing it up. here's my output though I'm not sure why I'm getting the 1 before weight and the random 1 at the bottom.

Please enter the candidate's information(enter 'X' to exit)Gender: m
height: 80
1weight: 130
1
I know what the deal is. Its outputting heightOk and weightOk as 1 because it stores true as 1 and I'm outputting it.
Topic archived. No new replies allowed.