码迷,mamicode.com
首页 > 其他好文 > 详细

体重指数程序

时间:2017-06-17 19:35:59      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:space   out   aar   oat   string   turn   ret   ons   输入   

//体重指数程序
#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;
}

 

体重指数程序

标签:space   out   aar   oat   string   turn   ret   ons   输入   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!