-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathbmi.cpp
33 lines (26 loc) · 1.26 KB
/
bmi.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double weight, height, bmi;
// Get user input for weight (in kilograms) and height (in meters)
cout << "Enter your weight in kilograms: ";
cin >> weight;
cout << "Enter your height in meters: ";
cin >> height;
// Calculate BMI
bmi = weight / pow(height, 2);
// Display the BMI value
cout << "Your BMI is: " << bmi << endl;
// Provide tips based on BMI value
if (bmi < 18.5) {
cout << "You are underweight. To improve your BMI, consider gaining some weight in a healthy way. Consult with a nutritionist or doctor if necessary." << endl;
} else if (bmi >= 18.5 && bmi < 24.9) {
cout << "Your BMI is within the healthy range. Maintain a balanced diet and regular exercise to stay healthy." << endl;
} else if (bmi >= 25.0 && bmi < 29.9) {
cout << "You are overweight. To improve your BMI, consider a balanced diet and regular exercise. Consult with a nutritionist or doctor for a personalized plan." << endl;
} else {
cout << "You are obese. It's important to focus on improving your BMI for your health. Consult with a healthcare professional for a personalized plan." << endl;
}
return 0;
}