/* Body Mass Index - This program calculates and displays a person's body mass
index (BMI). A person's BMI is calculated with the following formula:
* BMI = weight * 703 / height²
where weight is measured in pounds and height is measured in inches. The
program displays a message indicating whether the person has optimal weight,
is underweight, or is overweight. A sedentary person's weight is considered
optimal:
* if his or her BMI is between 18.5 and 25.
* if the BMI is less than 18.5 the person is considered to be underweight *
* if the BMI value is greater than 25, the person is considered to be
overweight */
#include "Utility.h"
int main()
{
/* Hold the BMI, weight and height, and BMI */
double weight,
height,
BMI;
/* Ask the user for his or her weight and height */
cout << "Enter your weight in pounds: ";
cin >> weight;
cout << "Enter your height in inches: ";
cin >> height;
BMI = weight * 703 / pow(height, 2);
/* Determine whether the persons weight is optimal, underweight or
overweight and display the result */
cout << showpoint << fixed << setprecision(2);
if (BMI >= 18.5 && BMI <= 25)
{
cout << "Your weight is optimal";
}
else if (BMI < 18.5)
{
cout << "You are underweight!\n";
}
else if (BMI > 25)
{
cout << "You are overweight";
}
pauseSystem();
return 0;
}
Friday, November 18, 2016
Programming Challenge 4.5 - Body Mass Index
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment