-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsource.cpp
More file actions
68 lines (59 loc) · 1.42 KB
/
Copy pathsource.cpp
File metadata and controls
68 lines (59 loc) · 1.42 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <iostream>
using namespace std;
static double CvrtInch(double feet, double inch) {
feet = feet * 12;
double total = feet + inch;
return total;
}
static double Step1(double weightP) {
double ans = weightP * 0.45;
return ans;
}
static double Step2(double heightI) {
double ans = heightI * 0.025;
return ans;
}
static double Step3(double heightM) {
double ans = heightM * heightM;
return ans;
}
static double Step4(double weightKG, double step3) {
double ans = weightKG / step3;
return ans;
}
static void sortResults(double BMI) {
cout << "BMI: " << BMI << endl;
if (BMI < 18.5) {
cout << "Underweight" << endl;
}
else if (BMI >= 18.5 && BMI <= 24.9) {
cout << "Normal Weight" << endl;
}
else if (BMI >= 25 && BMI <= 29.9) {
cout << "Overweight" << endl;
}
else if (BMI >= 30) {
cout << "Obese" << endl;
}
else {
cout << "Error: BMI not sorted correctly" << endl;
}
}
int main() {
cout << "Enter the feet part of height"<<endl;
double feet;
cin >> feet;
cout << "Enter the inches part of the height" << endl;
double inch;
cin >> inch;
cout << "Enter the weight in pounds" << endl;
double weight;
cin >> weight;
double totalIn = CvrtInch(feet, inch);
double weightkg = Step1(weight);
double heightM = Step2(totalIn);
double heightsq = Step3(heightM);
double BMI = Step4(weightkg, heightsq);
sortResults(BMI);
return 0;
}