having trouble with selection control operators if and if else

I'm trying to write a program that calculates BMI and the math checks out for the equation. My problem is getting it to prompt the statement that corresponds with the BMI range that I've programmed. This is what I got.

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
int Weight;
int Height;
float BodyMassIndex;
cout << " In order to calculate your BMI, please enter your weight in pounds and your height in inches in the following prompts." ;

cout << "Weight (lbs.):";

cin >> Weight;

cout << "Height (in.):" ;

cin >> Height;


BodyMassIndex = ( Weight / pow(Height , 2) ) * 703;

cout << "Your Body Mass Index is:" << setprecision(2) << fixed << BodyMassIndex << endl;


if(BodyMassIndex < 15.0)
{
cout << "You are very severely underweight, get medical help. " << endl;
}
if((BodyMassIndex >= 15.0) && (BodyMassIndex <= 15.9));
{
cout << "You are severely underweight, you really could use a hamburger." << endl;
}
if ((BodyMassIndex >= 16.0) && (BodyMassIndex <= 18.4));
{
cout << "You are underweight, try adding a few more pounds but be wise about it." << endl;
}
if ((BodyMassIndex >= 18.5) && (BodyMassIndex <= 24.9));
{
cout << "You are at a healthy weight, now just maintain it." << endl;
}
if ((BodyMassIndex >= 25.0) && (BodyMassIndex <= 29.9));
{
cout << "You are overweight try eating a little less or get more exercise." << endl;
}
if((BodyMassIndex >= 30.0) && (BodyMassIndex <= 34.9));
{
cout << "You are at class one obesity, moderately obese." << endl;
}
if((BodyMassIndex >= 35.0) && (BodyMassIndex <= 40.0));
{
cout << "You are at class two obesity, severely obese." << endl;
}
if(BodyMassIndex > 40.0);
{
cout << "You are at class three obesity, very severely obese." << endl;
}
return 0;

}
Any help is welcome and appreciated!
Please edit your post and format your code.
You can do this by adding [code] and [/code] around your actual code, e.g. [code] {code here;} [/code]

if(...);
if-statements shouldn't have semi-colons (;) at the end of them. Remove them.

Also, think about this: What happens when my BMI is 18.45?

According to your program, what happens when my BMI is 34.97?
Last edited on
I applied the changes and I got what I wanted. I also changed the set precision to one to fix the error two decimal places would have with the rest of the program. Thanks!
Note that setprecision only affects how things are printed, it doesn't affect any if-else logic. What I said before still applies, unless you changed the actual logic (Which you may have done, I don't know exactly what you changed).
Topic archived. No new replies allowed.