#include <iostream>
#include <string>
void getData(double& weight, double& height)
{
std::cout << "Please enter your weight (in kilograms): ";
std::cin >> weight;
std::cout << "Please enter your height (in meters): ";
std::cin >> height;
}
double calcBMI(double weight, double height)
{
double BMI = weight /(height * height);
return BMI;
}
std::string displayFitnessResults(double BMI)
{
std::string res = "";
if(BMI < 18.5)
res = "Underweight";
else if(BMI >= 18.5 && BMI <= 24.9)
res = "Healthy";
else if(BMI >= 25.0 && BMI <= 29.9)
res = "Overweight";
else if (BMI >= 30.0)
res = "Obese";
return res;
}
int main()
{
double weight, height;
getData(weight, height);
double BMI = calcBMI(weight, height);
std::cout << "Your Body Mass Index (BMI) is " << BMI << std::endl;
std::string ResFitness = displayFitnessResults(BMI);
std::cout << ResFitness << std::endl;
}
Comments
Leave a comment