返回列表 發帖
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
cout<<"<BMI計算機>"<<endl;
re:
    float h,w,b;
    string x;
    cout<<"請輸入你的大名:"<<endl;
    cin>>x;
    cout<<"清輸入你的身高(公分):";
    cin>>h;
    cout<<"清輸入你的體重(公斤):";
    cin>>w;
    cout<<endl;
    cout<<"親愛的"<<x<<",你的BMI值為:"<<w/h/h*10000<<endl;
    if (w/h/h*10000>=27 &&w/h/h*10000<35){
        cout<<"重度肥胖!!你需要立即注意你的飲食,因為你的生命正受到嚴重威脅!"<<endl;
    }
    else if (w/h/h*10000<27 &&w/h/h*10000>=24){
        cout<<"過重!!唔..該減肥了!"<<endl;
    }
    else if (w/h/h*10000<24 &&w/h/h*10000>=18.5){
        cout<<"正常範圍!!繼續保持!"<<endl;
    }
    else if (w/h/h*10000<18.5 &&w/h/h*10000>=10){
        cout<<"體重過輕!!你需要多吃點喔!"<<endl;
    }
    else{
        cout<<"不要再玩了啦! 你是怪物嗎? 再胡鬧小心我扁你!"<<endl;
    }
    cout<<endl;
    goto re;
    system("pause");
    return 0;
}

TOP

返回列表