1 //体重指数程序
2 #include <fstream>
3 #include <iostream>
4 #include <iomanip>
5 #include <string>
6 using namespace std;
7
8 int main()
9 {
10 const int BMI_CONSTANT = 703;
11 float weight;
12 float height;
13 float bodyMassIndex;
14 bool dadtaAreOk;
15
16 cout << "。。。的" << endl;
17 cout << "输入体重(千克) " << endl;
18 cin >> weight;
19 weight = weight / 0.4535924;
20 cout << "输入升高(厘米) " << endl;
21 cin >> height;
22 height = height / 2.54;
23
24 if (weight < 0 || height < 0)
25 dadtaAreOk = false;
26 else
27 dadtaAreOk = true;
28
29 if (dadtaAreOk)
30 {
31 bodyMassIndex = weight * BMI_CONSTANT / (height * height);
32
33 cout << "your body indedx is " << bodyMassIndex
34 << "." << endl;
35 cout << "interpretation ans instructiobn:" << endl;
36 if (bodyMassIndex < 20)
37 cout << "体重不不足,喝杯奶昔" << endl;
38 else if (bodyMassIndex <= 25)
39 cout << "正常,喝杯牛奶" << endl;
40 else if (bodyMassIndex <= 30)
41 cout << "超重,喝杯冰茶" << endl;
42 else
43 cout << "超重,看医生吧" << endl;
44 }
45 else
46 cout << "数据有问题" << endl;
47
48 cin.get();
49 cin.get();
50
51 return 0;
52 }