-
Notifications
You must be signed in to change notification settings - Fork 0
/
BMI calc.cpp
49 lines (31 loc) · 1.22 KB
/
BMI calc.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
cout << "***********BMI CALCULATOR***********" << endl;
string name;
cout << "Hello Welcome to BMI CALCULATOR, what is your name?: ";
getline(cin, name);
cout << "Hello " << name << "!" << endl;
int kg;
float met;
cout << "Enter your weight in kilograms: ";
cin >> kg;
cout << "Enter your height in meters: ";
cin >> met;
cout << "\n";
float BMI = kg/(pow(met, 2));
if (BMI < 18.5) {
cout << "Hello " << name << "," << " your BMI is" << setprecision(2) << BMI << " You are underweight!";
} else if (BMI >= 18.5 && BMI < 25.0) {
cout << "Hello " << name << "," << " your BMI is" << setprecision(2) << BMI << " You are healthy!";
} else if (BMI >= 25.0 and BMI < 30.0) {
cout << "Hello " << name << "," << " your BMI is" << setprecision(2) << BMI << " You are overweight!";
} else if (BMI >= 30.0) {
cout << "Hello " << name << "," << " your BMI is" << setprecision(2) << BMI << " You are obese!";
} else {
cout << "Invalid Input";
}
return 0;
}