-
Notifications
You must be signed in to change notification settings - Fork 0
/
02.14.BodyMassIndex.cpp
75 lines (64 loc) · 2.36 KB
/
02.14.BodyMassIndex.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
#include <iostream>
using namespace std;
/*
========================================================================
02.13. Body Mass Index
by : #bayuyudhasaputra
lang : IDN (Bahasa Indonesia)
------------------------------------------------------------------------
Masalah :
Body Mass Index (BMI) is a measure of health on weight. It can be
calculated by taking your weight in kilograms and dividing by the square
of your height in meters. Write a program that prompts the user to enter
a weight in kilograms and height in centimeters and displays the BMI!
==========================================================================
*/
int main()
{
cout << endl
<< "================================================================"
<< endl
<< endl
<< "02.14. Body Mass Index"
<< endl
<< endl
<< "----------------------------------------------------------------"
<< endl
<< endl;
// 1. Input berat badan dalam Kg
cout << "Input berat badan dalam kilogram (Misal. 70): ";
double massaBadan;
cin >> massaBadan;
cout << endl
<< endl
<< "(Anda menginput " << massaBadan << " Kg) "
<< endl
<< endl;
// 2. Input tinggi badan dalam cm
cout << "Input tinggi badan dalam centimeter (Misal. 163): ";
double tinggiBadan;
cin >> tinggiBadan;
cout << endl
<< endl
<< "(Anda menginput " << tinggiBadan << " cm) "
<< endl
<< endl;
// 3. Hitung BMI
double BMI;
BMI = massaBadan / (tinggiBadan * tinggiBadan);
// 4. Tampilkan hasil BMI.
cout << "Jadi, BMI dengan " << endl << endl
<< " Massa badan " << massaBadan << " Kg," << endl << endl
<< " Tinggi badan " << tinggiBadan << " cm," << endl << endl
<< "adalah " << BMI
<< endl
<< endl
<< "================================================================"
<< endl;
return 0;
}
/*
Liang. 2014. Introduction to Programming with C++ 3rd Edition.
London : Pearson Education.
https://www.pearson.com/en-us/subject-catalog/p/Liang-Companion-Website-for-Introduction-to-Programming-with-C-Access-to-Videonotes-3rd-Edition/P200000003422/978013338026
*/