Design a program that calculates a person’s body mass index (BMI).
BMI is often used to determine whether a person with a sedentary
lifestyle is overweight or underweight for his or her height. A person’s
BMI is calculated with the following formula:
In the formula, weight is measured in pounds and height is measured in
inches. Enhance the program so it displays a message indicating
whether the person has optimal weight, is underweight, or is overweight.
A sedentary person’s weight is considered to be 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 <iostream>
using namespace std;
int main() {
float wieght = 100, height = 50;
std::cout << "This program calculates the BMI." << std::endl;
std::cout << "Enter the wieght (in lbs): " << std::endl;
std::cin >> wieght;
std::cout << "Enter the height (in inches): " << std::endl;
std::cin >> height;
float BMI = 703*wieght/(height*height);
cout<<"BMI of the person is: "<<BMI<<"\n";
if(BMI >= 18.5 && BMI <= 25){
std::cout << "Weight of the person is optimal." << std::endl;
}
else if(BMI < 18.5){
std::cout << "Person is underweight." << std::endl;
}
else if(BMI > 25){
std::cout << "Person is overweight." << std::endl;
}
return 0;
}
Comments
Leave a comment