#include <iostream>
#include <string>
using namespace std;
float calculateBMI(float weight, float height);
string categorizeBMI(float bmi);
void displayResult(float bmi, string category);
int main(){
char continueProgram = 'y';
while (continueProgram == 'y' || continueProgram == 'Y'){
float weight, height;
cout << "Enter weight in kilograms: ";
cin >> weight;
cout << "Enter height in meters: ";
cin >> height;
float bmi = calculateBMI(weight, height);
string category = categorizeBMI(bmi);
displayResult(bmi, category);
cout << "Do you want to calculate BMI for another person? (y/n): ";
cin >> continueProgram;
}
cout << "Thank you for uing the BMI Calculator. Goodbye!" << endl;
return 0;
}
float calculateBMI(float weight, float height){
return weight / (height * height);
}
string categorizeBMI(float bmi){
if (bmi < 18.5){
return "Underweight";
} else if (bmi >= 18.5 && bmi < 24.9){
return "Normal weight";
} else if (bmi >= 25 && bmi < 29.9){
return "Overweight";
}else{
return "Obesity";
}
}
void displayResult(float bmi, string category){
cout << "Your BMI is: " << bmi << endl;
cout << "BMI Cateogry: " << category << endl;
}