Almost done. Just need to fix this one error.

//Ja-Mesz Walton
//3/6/16
//Midterm project regarding calculating Body Mass Index
// CIS1111

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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
 #include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>
using namespace std; 

int main()
{
	//named constants
	const double BMI_MIN = 18.5;
	const double BMI_MAX = 25;

	//Delcared variables
	string userName;
	double bmi;
	int gendertype;
	double weight;
	int height;
	double calories;


	cout << "This program calculates Body Mass Index and daily calorie recommendations." << endl;

	//input information
	cout << "Enter your name:";
	getline(cin, userName);

	cout << "Enter your weight in pounds:";
	cin >> weight;

	cout << "Enter your height in inches:";
	cin >> height;

	cout << "Select your gender and activity level from this list." << endl;
	cout << "1. Moderately Active Female" << endl;
	cout << "2. Moderately Inactive Female" << endl;
	cout << "3. Moderately Active Man" << endl;
	cout << "4. Moderately Inactive Man" << endl;
		// Enter Gender type
	cout << " Enter your selection: ";
	cin >> gendertype; 

	if (gendertype == 1)
	{
		//Active female
		calories = weight * 12;
		if (weight < BMI_MIN) //Active Female is underweight
		{
			std::cout << "Weight Category: Underweight" << endl;
		}
		else if (weight > BMI_MAX) //Active Female is overweight
		{
			std::cout << "Weight Category: Overweight" << endl;
		}
		else // Active Female is optimum weight
		{
			std::cout << "Weight Category: Optimum" << endl;
	}
		

			{
			if (gendertype == 2)
				{
				 //Inactive female
				if (weight < BMI_MIN) // Inactive female is underweight
				{	
					std::cout << "Weight Category: Underweight" << endl;
				}
				else if (weight > BMI_MAX) // Inactive Female is overweight
				{
					std::cout << "Weight Category: Overweight" << endl;
				}
				else // Inactive Female is optimum weight
				{	
					std::cout << "Weight Category: Optimum" << endl;
			}
		
						{
						if (gendertype == 3)
							{
							//Active Male 
							if (weight < BMI_MIN) //Active Male is underweight
							{
								std::cout << "Weight Category: Underweight" << endl;
							}
							else if (weight > BMI_MAX) //Active Male is overweight
							{
								std::cout << "Weight Category: Overweight" << endl;
							}
							else // Active Male is optimum weight	
							{	
								std::cout << "Weight Category: Optimum" << endl;
						}
	
								{
								if (gendertype == 4)
									{
									// Inactive Male
									if (weight < BMI_MIN) // Inactive Male is underweight
									{	
										std::cout << "Weight Category: Underweight" << endl;
									}
									else if (weight > BMI_MAX) // Inactive Male is overweight
									{
										std::cout << "Weight Category: Overweight" << endl;
									}	
									else // Inactive Male is optimum weight
									{
										std::cout << "Weight Category: Optimum" << endl;
			
								}
	 
	
											// Body Mass Index (BDM) formula
											bmi = weight * 703 / (height * height);

											if (bmi < BMI_MIN)
											{
												//Underweight
												std::cout << "Weight Category: Underweight" << endl;
											}
											else if (bmi > BMI_MAX)
											{
												//Overweight
												std::cout << "Weight Category: Overweight" << endl;
											}
											else
											{
												//Optimal weight
												std::cout << "Weight Category: Optimum" << endl;
											}

	return 0;

}


Last edited on
Please post your code using code tags when posting on here.
How? I'm new here.
Last edited on
Look at the tools you can use when making/editing a post. One of these tools has an icon that looks like <> . If you highlight your code, and select this icon, it will put the code tags around it which will give line #s to each line and color certain things to make it more readable.

If you can't figure it out, look at http://www.cplusplus.com/articles/jEywvCM9/
Last edited on
Use the thread you already created.
I'm doing that and hitting the code button, but its not doing that.
Is your code not highlighted? You can try manually typing [ code ] before the code and [ / code ] after the code (without spaces)
Last edited on
Done.
Line 61: { should be }
Line 78: { should be }
Line 95: { should be }
Line 112: Missing }


You really should properly indent your code so that you can spot these easier like how the code tags had indented it.
Last edited on
I don't know how to do that though. I'm sorry. I'm really knew to doing all this.
Basically every time you have a { you should indent once on the next line and every time you have } you should go back one indention on the next line.

1
2
3
4
5
6
7
if (blah)
{
	if (whatever)
	{
		beepbop();
	}
}


Makes it a lot easier to spot brace errors ( { and } )
Last edited on
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
//Ja-Mesz Walton
//3/6/16
//Midterm project regarding calculating Body Mass Index
// CIS1111

[code]#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>
using namespace std; 

int main()
{
	//named constants
	const double BMI_MIN = 18.5;
	const double BMI_MAX = 25;

	//Delcared variables
	string userName;
	double bmi;
	int gendertype;
	double weight;
	int height;
	double calories;


	cout << "This program calculates Body Mass Index and daily calorie recommendations." << endl;

	//input information
	cout << "Enter your name:";
	getline(cin, userName);

	cout << "Enter your weight in pounds:";
	cin >> weight;

	cout << "Enter your height in inches:";
	cin >> height;

	cout << "Select your gender and activity level from this list." << endl;
	cout << "1. Moderately Active Female" << endl;
	cout << "2. Moderately Inactive Female" << endl;
	cout << "3. Moderately Active Man" << endl;
	cout << "4. Moderately Inactive Man" << endl;
		// Enter Gender type
	cout << " Enter your selection: ";
	cin >> gendertype; 

	if (gendertype == 1)
	{
		//Active female
		calories = weight * 12;
		if (weight < BMI_MIN) //Active Female is underweight
		{
			std::cout << "Weight Category: Underweight" << endl;
		}
		else if (weight > BMI_MAX) //Active Female is overweight
			{
			std::cout << "Weight Category: Overweight" << endl;
			}
		else // Active Female is optimum weight
		}
		std::cout << "Weight Category: Optimum" << endl;
	}
		

			{
			if (gendertype == 2)
				{
					 //Inactive female
				if (weight < BMI_MIN) // Inactive female is underweight
				{	
					std::cout << "Weight Category: Underweight" << endl;
				}
				else if (weight > BMI_MAX) // Inactive Female is overweight
				{
					std::cout << "Weight Category: Overweight" << endl;
				}
				else // Inactive Female is optimum weight
				}	
				std::cout << "Weight Category: Optimum" << endl;
			}
		
						{
						if (gendertype == 3)
							{
							//Active Male 
							if (weight < BMI_MIN) //Active Male is underweight
							{
								std::cout << "Weight Category: Underweight" << endl;
							}
							else if (weight > BMI_MAX) //Active Male is overweight
							{
								std::cout << "Weight Category: Overweight" << endl;
							}
							else // Active Male is optimum weight	
						}	
								std::cout << "Weight Category: Optimum" << endl;
							}
	
								{
								if (gendertype == 4)
									{
									// Inactive Male
									if (weight < BMI_MIN) // Inactive Male is underweight
									{	
										std::cout << "Weight Category: Underweight" << endl;
									}
									else if (weight > BMI_MAX) // Inactive Male is overweight
									{
										std::cout << "Weight Category: Overweight" << endl;
									}	
									else // Inactive Male is optimum weight
								}
										std::cout << "Weight Category: Optimum" << endl;
								}
	 
	
											// Body Mass Index (BDM) formula
											bmi = weight * 703 / (height * height);

											if (bmi < BMI_MIN)
											{
												//Underweight
												std::cout << "Weight Category: Underweight" << endl;
											}
											else if (bmi > BMI_MAX)
											{
												//Overweight
												std::cout << "Weight Category: Overweight" << endl;
											}
											else
											{
												//Optimal weight
												std::cout << "Weight Category: Optimum" << endl;
											}
return 0;
} [code]	
Last edited on
Once again you just have more brace errors.
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//Ja-Mesz Walton
//3/6/16
//Midterm project regarding calculating Body Mass Index
// CIS1111

#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>
using namespace std;

int main()
{
	//named constants
	const double BMI_MIN = 18.5;
	const double BMI_MAX = 25;

	//Delcared variables
	string userName;
	double bmi;
	int gendertype;
	double weight;
	int height;
	double calories;


	cout << "This program calculates Body Mass Index and daily calorie recommendations." << endl;

	//input information
	cout << "Enter your name:";
	getline(cin, userName);

	cout << "Enter your weight in pounds:";
	cin >> weight;

	cout << "Enter your height in inches:";
	cin >> height;

	cout << "Select your gender and activity level from this list." << endl;
	cout << "1. Moderately Active Female" << endl;
	cout << "2. Moderately Inactive Female" << endl;
	cout << "3. Moderately Active Man" << endl;
	cout << "4. Moderately Inactive Man" << endl;
	// Enter Gender type
	cout << " Enter your selection: ";
	cin >> gendertype;

	if (gendertype == 1)
	{
		//Active female
		calories = weight * 12;
		if (weight < BMI_MIN) //Active Female is underweight
		{
			std::cout << "Weight Category: Underweight" << endl;
		}
		else if (weight > BMI_MAX) //Active Female is overweight
		{
			std::cout << "Weight Category: Overweight" << endl;
		}
		else // Active Female is optimum weight
		{
			std::cout << "Weight Category: Optimum" << endl;
		}
	}

	if (gendertype == 2)
	{
		//Inactive female
		if (weight < BMI_MIN) // Inactive female is underweight
		{
			std::cout << "Weight Category: Underweight" << endl;
		}
		else if (weight > BMI_MAX) // Inactive Female is overweight
		{
			std::cout << "Weight Category: Overweight" << endl;
		}
		else // Inactive Female is optimum weight
		{
			std::cout << "Weight Category: Optimum" << endl;
		}
	}
	
	if (gendertype == 3)
	{
		//Active Male 
		if (weight < BMI_MIN) //Active Male is underweight
		{
			std::cout << "Weight Category: Underweight" << endl;
		}
		else if (weight > BMI_MAX) //Active Male is overweight
		{
			std::cout << "Weight Category: Overweight" << endl;
		}
		else // Active Male is optimum weight
		{
			std::cout << "Weight Category: Optimum" << endl;
		}
	}

	if (gendertype == 4)
	{
		// Inactive Male
		if (weight < BMI_MIN) // Inactive Male is underweight
		{
			std::cout << "Weight Category: Underweight" << endl;
		}
		else if (weight > BMI_MAX) // Inactive Male is overweight
		{
			std::cout << "Weight Category: Overweight" << endl;
		}
		else // Inactive Male is optimum weight
		{
			std::cout << "Weight Category: Optimum" << endl;
		}
	}

	// Body Mass Index (BDM) formula
	bmi = weight * 703 / (height * height);

	if (bmi < BMI_MIN)
	{
		//Underweight
		std::cout << "Weight Category: Underweight" << endl;
	}
	else if (bmi > BMI_MAX)
	{
		//Overweight
		std::cout << "Weight Category: Overweight" << endl;
	}
	else
	{
		//Optimal weight
		std::cout << "Weight Category: Optimum" << endl;
	}

	return 0;
}


You'll probably want to review your logic however... Since you are comparing weight to bmi.
Last edited on
OMG! You sir are awesome. I really appreciate your help and your patience with me. It works until it ask me for the gender type, I can't select the gender type or type it in. Is there something I have to do to fix that?
Last edited on
I'm not sure what you mean. I'm able to select a gender type. The only issue i'm seeing is all the logic after you select the gender type doesn't make sense.
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
ok. Is the logic much better now after this? 
//Ja-Mesz Walton
//3/6/16
//Midterm project regarding calculating Body Mass Index
// CIS1111

#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>
using namespace std; 

int main()
{
	//named constants
	const double BMI_MIN = 18.5;
	const double BMI_MAX = 25;

	//Delcared variables
	string userName;
	double bmi;
	int gendertype;
	double weight;
	int height;
	double calories;


	cout << "This program calculates Body Mass Index and daily calorie recommendations." << endl;

	//input information
	cout << "Enter your name:";
	getline(cin, userName);

	cout << "Enter your weight in pounds:";
	cin >> weight;

	cout << "Enter your height in inches:";
	cin >> height;

	cout << "Select your gender and activity level from this list." << endl;
	cout << "1. Moderately Active Female" << endl;
	cout << "2. Moderately Inactive Female" << endl;
	cout << "3. Moderately Active Man" << endl;
	cout << "4. Moderately Inactive Man" << endl;
		// Enter Gender type
	cout << " Enter your selection: ";
	cin >> gendertype; 

	if (gendertype == 1)
	{
		//Active female
		calories = weight * 12;
		if (weight < BMI_MIN) //Active Female is underweight
		{
			std::cout << "Weight Category: Underweight" << endl;
		}
		else if (weight > BMI_MAX) //Active Female is overweight
			{
			std::cout << "Weight Category: Overweight" << endl;
			}
		else // Active Female is optimum weight
		{
		std::cout << "Weight Category: Optimum" << endl;
		}
}
		

		if (gendertype == 2)
		{
			//Inactive female
			calories= weight *10;
			if (weight < BMI_MIN) // Inactive female is underweight
			{	
				std::cout << "Weight Category: Underweight" << endl;
			}
			else if (weight > BMI_MAX) // Inactive Female is overweight
			{
				std::cout << "Weight Category: Overweight" << endl;
			}
			else // Inactive Female is optimum weight
			{	
				std::cout << "Weight Category: Optimum" << endl;
			}
		}
				
					if (gendertype == 3)
					{
							//Active Male
							calories= weight *15;
							if (weight < BMI_MIN) //Active Male is underweight
							{
								std::cout << "Weight Category: Underweight" << endl;
							}
							else if (weight > BMI_MAX) //Active Male is overweight
							{
								std::cout << "Weight Category: Overweight" << endl;
							}
							else // Active Male is optimum weight	
							{	
								std::cout << "Weight Category: Optimum" << endl;
							}
					}
							
					if (gendertype == 4)
					{
							// Inactive Male
							calories=weight *13;
								if (weight < BMI_MIN) // Inactive Male is underweight
								{	
									std::cout << "Weight Category: Underweight" << endl;
								}
								else if (weight > BMI_MAX) // Inactive Male is overweight
								{
									std::cout << "Weight Category: Overweight" << endl;
								}	
								else // Inactive Male is optimum weight
								{
									std::cout << "Weight Category: Optimum" << endl;
								}
					}
	
					// Body Mass Index (BDM) formula
					bmi = weight * 703 / (height * height);

					if (bmi < BMI_MIN)
					{
							//Underweight
							std::cout << "Weight Category: Underweight" << endl;
					}
					else if (bmi > BMI_MAX)
					{
							//Overweight
							std::cout << "Weight Category: Overweight" << endl;
					}
					else
					{
							//Optimal weight
							std::cout << "Weight Category: Optimum" << endl;
					}
					return 0;
}	
Hey there sir. I just want to thank you so much for help me out a lot. I unfortunately am running out of time and I have to drop this in the dropbox, even though it's not turning out the way I want it to. I really appreciate your help and your patience in this assignment. I would literally have flunk this, but you help me out tremendously along with booradley60. I thank you guys for your help.
One more thing ...

If you configure your editor to convert tabs to spaces (3 or 4 is good) then your code will look much better when posted here. This site converts tabs to 8 spaces, so that's why half of your code is off my screen (way out to the right), some of them even look like 2 tabs worth of indenting.

If you have a half decent editor with your IDE, it should do this stuff auto-magically :+)

It's also possible to use a code formatter after the fact. A-Style and llvm-format deem to be popular.

Good Luck !!
Topic archived. No new replies allowed.