COMP2113
COMP2113_ENGG1340 Programming technologies and Computer programming II [Section 2BC] [2023]
Loading...
Searching...
No Matches
checkpoint3.8.cpp
Go to the documentation of this file.
1/*
2The formulas for calculating BMI are
3BMI = weight(kg) / (height(m) * height(m))
4Create a BMI calculator application that reads the user’s weight in kilograms
5and then height in meters, then calculates and displays the user’s body mass index.
6Also, the application should display the following information so the user
7can evaluate his/her BMI:
8BMI VALUES
9Underweight: less than 18.5
10Normal: between 18.5 and 24.9
11Overweight: between 25 and 29.9
12Obese: 30 or greater
13
14Example
15Assume the user is 64 kg in weight and 1.6 m in height, input as follows:
1664 1.6
17The program outputs the following:
18Your BMI = 25
19BMI VALUES
20Underweight: less than 18.5
21Normal: between 18.5 and 24.9
22Overweight: between 25 and 29.9
23Obese: 30 or greater
24*/
25
26#include <iostream>
27using namespace std;
28
29int main() {
30 int weight; double height;
31 // take two inputs
32 cin >> weight >> height;
33 cout << "Your BMI = " << weight/(height*height) << endl;
34 cout << "BMI VALUES" << endl;
35 cout << "Underweight: less than 18.5" << endl;
36 cout << "Normal: between 18.5 and 24.9" << endl;
37 cout << "Overweight: between 25 and 29.9" << endl;
38 cout << "Obese: 30 or greater";
39 return 0;
40}
int main()