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
/*
2
The formulas for calculating BMI are
3
BMI = weight(kg) / (height(m) * height(m))
4
Create a BMI calculator application that reads the user’s weight in kilograms
5
and then height in meters, then calculates and displays the user’s body mass index.
6
Also, the application should display the following information so the user
7
can evaluate his/her BMI:
8
BMI VALUES
9
Underweight: less than 18.5
10
Normal: between 18.5 and 24.9
11
Overweight: between 25 and 29.9
12
Obese: 30 or greater
13
14
Example
15
Assume the user is 64 kg in weight and 1.6 m in height, input as follows:
16
64 1.6
17
The program outputs the following:
18
Your BMI = 25
19
BMI VALUES
20
Underweight: less than 18.5
21
Normal: between 18.5 and 24.9
22
Overweight: between 25 and 29.9
23
Obese: 30 or greater
24
*/
25
26
#include <iostream>
27
using namespace
std;
28
29
int
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
}
main
int main()
Definition
checkpoint3.8.cpp:29
Module3
checkpoint3.8.cpp
Generated on Sun Sep 29 2024 16:39:53 for COMP2113 by
1.12.0