If/else help

I have the following if/else I am having trouble with, it is displaying both the if and the else and I am lost as to what to do with it, heres the code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
	//Display weight category in if/else 18.5 to 25 
	if (displayBmi <= 18.4)
	{
		// Output underweight
		cout << "You are currently underweight, eat more!\n";
	}

	if (displayBmi >= 25.1)
	{
		// Output overweight.
		cout << "You are currently overweight.  Put the cake DOWN!\n";
	}

	else
	{
		// Output optimal.
		cout << "You are currently in the optimal BMI category, great job!\n";
	}


this is for a BMI calculator and no matter the bmi number it will display the underweight "if" AND the else, which is the optimal. So i want it to basically say.

If bmi is less than or equal to 18.4 then its underweight
if bmi is greater than or equal to 25.1 then its overweight
If it is in between those two ranges it is optimal
1
2
3
4
5
6
7
8
9
if (...)
{
}
else if (...)  // watch this
{
}
else
{
}
ok, that solved the double post problem, however, now it is still showing only the first "if" (underweight version)
Do you have a debugger? Set a breakpoint at the first if. Check the value of displayBmi.
you do not have to double post: http://www.cplusplus.com/forum/general/143558/
Topic archived. No new replies allowed.