首页 > 其他 > 详细

体重指数程序

时间:2017-06-17 19:14:23      阅读:255      评论:0      收藏:0      [点我收藏+]

//体重指数程序
#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

int main()
{
const int BMI_CONSTANT = 703;
float weight;
float height;
float bodyMassIndex;
bool dadtaAreOk;

cout << "。。。的士速递发的" << endl;
cout << "输入体重(千克) " << endl;
cin >> weight;
weight = weight / 0.4535924;
cout << "输入升高(厘米) " << endl;
cin >> height;
height = height / 2.54;

if (weight < 0 || height < 0)
dadtaAreOk = false;
else
dadtaAreOk = true;

if (dadtaAreOk)
{
bodyMassIndex = weight * BMI_CONSTANT / (height * height);

cout << "your body indedx is " << bodyMassIndex
<< "." << endl;
cout << "interpretation ans instructiobn:" << endl;
if (bodyMassIndex < 20)
cout << "体重不不足,喝杯奶昔" << endl;
else if (bodyMassIndex <= 25)
cout << "正常,喝杯牛奶" << endl;
else if (bodyMassIndex <= 30)
cout << "超重,喝杯冰茶" << endl;
else
cout << "超重,看医生吧" << endl;
}
else
cout << "数据有问题" << endl;

cin.get();
cin.get();

return 0;
}

 

体重指数程序

原文:http://www.cnblogs.com/skylover/p/7040931.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!