please help me :(

i cant figure out why my if else statement wont work. every time i run the program it completely skips the statement and ends it.

1
2
3
4
5
6
7
8
9
10
11
12
13
//display user's weight status.
	if (bmi < 18.5)
	{ cout<< "Your BMI category is UNDERWEIGHT.";
	}
	else if (bmi >= 18.5 && bmi < 25)
	{ cout<< "Your BMI category is NORMAL.";
	}
	else if (bmi >= 25 && bmi < 30)
	{ cout<< "Your BMI category is OVERWEIGHT.";
	}
	else
	{ cout<< "Your BMI category is OBESE.";
	}//end if statement 
Where do you declare bmi? What comes before that code?
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
// This program calculates the the users's BMI and Target Heart Rate


#include <iostream>
using namespace std;

int main ()

{
	int weight,		// user's current weight in pounds
		age,		// user's current age in years
		height,		// user's current height in inches
		target;	// target heart rate

	char answer; // user's Y/N answer

	double bmi;		// body mass index

	cout<< "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" <<endl;
	cout<< "|||                                                             |||" <<endl;
	cout<< "|||           Welcome to Happy Valley Fitness Center!           |||" <<endl;
	cout<< "|||              Where We Care About Your Health                |||" <<endl;
	cout<< "|||                                                             |||" <<endl;
	cout<< "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" <<endl;


	cout<< "Let's check your current fitness level!" << endl;
	cout<< "We will determine your target heart rate and body mass index." <<endl;
	cout<< "All we need is your age, height, and weight." << endl;
	cout<< endl;
	//user enters age
	cout<< "How old are you?" <<endl;
	cin>> age;
	cout<< endl;
	//user enters height
	cout<< "What is your height in inches? (Remember 1 foot = 12 inches)" <<endl;
	cin>> height;
	cout<< endl;
	//user enters weight
	cout<< "What is your weight (in pounds)? " <<endl;
	cin>> weight;
	cout<< endl;

	//calculate bmi and target heart rate.
	bmi = (weight * 703.0) / (height * height);

	target = (220 - age) * 0.70;

	//display bmi and target heart rate.
	cout<< "The results are in!" <<endl;
	cout<< "Target heart rate: " <<endl;
	cout<< target <<endl;
	cout<< "Body Mass Index: " <<endl;
	cout<< bmi <<endl;

	//teach user about bmi
	cout<< "Learn more about your Body Mass Index (BMI). This number is a ratio of height to weight. It is an indication of your current body fat level." <<endl;
	cout<< "The Center for Disease Control guidelines for BMI are:" <<endl;
	cout<< "Below 18.5			Underweight" <<endl;
	cout<< "18.5 - 24.9			Normal" <<endl;
	cout<< "25.0 - 29.9			Overweight" <<endl;
	cout<< "30.0 and Above			Obese" <<endl;

	//display user's weight status.
	if (bmi < 18.5)
	{ cout<< "Your BMI category is UNDERWEIGHT.";
	}
	else if (bmi >= 18.5 && bmi < 25)
	{ cout<< "Your BMI category is NORMAL.";
	}
	else if (bmi >= 25 && bmi < 30)
	{ cout<< "Your BMI category is OVERWEIGHT.";
	}
	else
	{ cout<< "Your BMI category is OBESE.";
	}//end if statement 
apart from a few initialization errors, it seems to "work" for me. i.e. it went into line 75 with some test data I used.
figured it out, turns out all i needed to do was restart my software. -.-
Topic archived. No new replies allowed.