This repository has been archived by the owner on Aug 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeek2BMICalc.cpp
98 lines (84 loc) · 2.48 KB
/
Week2BMICalc.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Week2.cpp : This file contains the 'main' function. Program execution begins and ends there.
#include <iostream>
#include <string>
using namespace std;
int main()
{
//Variables to hold weight, height, input option, and BMI
string option;
float weight = 0;
float height = 0;
float calcHolding = 0;
float BMI = 0;
//If statement to allow for different height inputs
cout << "To enter your height in Feet & Inches, please type 'feet'\nTo enter your height in Centimeters, please type 'centimeter'\n: ";
cin >> option;
if (option == "feet") {
//Input for Feet
cout << "Enter your height in feet then inches\n Feet: ";
cin >> calcHolding;
//Input for Inches
cout << "Inches: ";
cin >> calcHolding;
//Conversion to cm
height = calcHolding * 12;
height = height + calcHolding;
height = height * 0.025;
}
else if (option == "centimeter") {
//Input for centimeters
cout << "Enter your height in centimeters\n: ";
cin >> height;
}
else {
cout << "Invalid choice, please restart program";
return 0;
}
//If statement to allow for different weight inputs
cout << "To enter your weight in pounds, please type 'pound'\nTo enter your weight in kilograms, type 'kilo'\n: ";
cin >> option;
if (option == "pound") {
//Input for pounds
cout << "Enter your weight in pounds\n: ";
cin >> calcHolding;
//Conversion to kilograms
weight = calcHolding * 0.45;
}
else if (option == "kilo") {
//Input for Kilos
cout << "Enter your weight in Kilos\n: ";
cin >> weight;
}
else {
cout << "Invalid option, please restart program";
return 0;
}
//Calculations to find BMI
calcHolding = height * height;
BMI = weight / calcHolding;
if (BMI < 18.5) {
cout << "You have a BMI of " << BMI << ". This means you are very Underweight.";
}
else if (BMI <= 18.5 && BMI > 12) {
cout << "You have a BMI of " << BMI << ". This means you are Underweight.";
}
else if (BMI >= 18.5 && BMI < 25) {
cout << "You have a BMI of " << BMI << ". This means you are a Healthy Weight.";
}
else if (BMI >= 25 && BMI < 30) {
cout << "You have a BMI of " << BMI << ". This means you are Overweight.";
}
else if (BMI >= 30 && BMI < 35) {
cout << "You have a BMI of " << BMI << ". This means you are Level 1 Obese";
}
else if (BMI >= 35 && BMI < 40) {
cout << "You have a BMI of " << BMI << ". This means you are Level 2 Obese";
}
else if (BMI >= 40) {
cout << "You have a BMI of " << BMI << ". This means you are Level 3 Obese";
}
else {
cout << "Invalid";
return 0;
}
}