im supposed to 1. Write a function that computes and returns a persons Body Mass \
Where weight is measured in pounds and height is measured in inches.
2. Create a Body Mass Index calculator UI where the user can type in his weight and height in feet and inches.
3. Look up the U.S. Department of Health and Human Services BMI categories for adults. Categorize the users information as Underweight, Normal, Overweight, or Obese based on BMI.
and when i run the program i get all of the options my if and else isnt working how i hoped.. help? thanks in advance
Here is an example, which purposely does not use your formulas and variables. You also might want to look at comparing the value of b to the criteria for underweight/overweight etc...
Look for main
do all the operations in main
finish
So if you don't put a call to your function in main, it won't happen. Look in my example. In line 16 in main, we call up the function. Otherwise, it would never get run!
At line 29, you reference the uninitialized variable bmi.
Your code is going to fail because you have never initialized this variable.
You never call the function BMI to do the calculation.
Your if logic is bogus. I've added braces, indentation and comments.
1 2 3 4 5 6 7 8 9 10
if (bmi < 18.5)
{ if (bmi >= 30) // this can never be true
cout << "Obesity";
elseif (bmi >= 25) // or this
cout << "Overwieght";
elseif (bmi >= 18.5) // or this
cout << "Normal weight";
}
else
cout << "Underweight";
PLEASE USE CODE TAGS (the <> formatting button) when posting code. http://v2.cplusplus.com/articles/jEywvCM9/
It makes it easier to read your code and it also makes it easier to respond to your post.