roberthsu2003 / cAndC-

51 stars 18 forks source link

作業1 #9

Closed roberthsu2003 closed 9 months ago

roberthsu2003 commented 9 months ago

https://depart.femh.org.tw/dietary/3OPD/BMI.htm

  • 請輸入身高
  • 請輸入體重
  • 輸出bmi值
  • 輸出目前狀態
roberthsu2003 commented 9 months ago
#include <iostream>
#include <math.h>
using namespace std;
/*
https://depart.femh.org.tw/dietary/3OPD/BMI.htm
請輸入身高體重,輸出BMI值
BMI<18.5體重過輕
18.5<=BMI<24體重正常
過重:24≦BMI<27
輕度肥胖:27≦BMI<30
中度肥胖:30≦BMI<35
重度肥胖:BMI≧35

*/
int main() {
  double 身高;
  double 體重;
  double BMI;

  cout << "請輸入身高(cm):";
  cin >> 身高;
  cout << "請輸入體重(kg):";
  cin >> 體重;

  BMI = 體重 / pow((身高/100),2);

  if(BMI < 18.5)
  {
    cout << "BMI值為:" << BMI << endl;
    cout << "體重過輕" << endl;
  }
    else if (18.5 <= BMI &&  BMI < 24)
    {
      cout << "BMI值為:" << BMI << endl;
      cout << "體重正常" << endl;
    }
    else if (24<= BMI  &&  BMI < 27)
    {
      cout << "BMI值為:%.2lf" << BMI << endl;
      printf("BMI是:%.2lf\n",BMI);
      cout << "過重" << endl;
    }
    else if (27<= BMI  &&  BMI < 30)
    {
      cout << "BMI值為:" << BMI << endl;
      cout << "輕度肥胖" << endl;
    }
    else if (30<= BMI  &&  BMI < 35)
    {
      cout << "BMI值為:" << BMI << endl;
      cout << "中度肥胖" << endl;
    }
    else if (35<= BMI)
    {
      cout << "BMI值為:" << BMI << endl;
      cout << "重度肥胖" << endl;
    }
  }
ZhouMuFen commented 9 months ago

https://replit.com/join/wrrmvxcwku-10306713579xyz

FangYu0113 commented 9 months ago
#include <iostream>

using namespace std;
/*
https://depart.femh.org.tw/dietary/3OPD/BMI.htm
請輸入身高
請輸入體重
輸出bmi值
輸出目前狀態
*/

int main()
{
    double height_in_cm,weight;
    double height_in_m;
    double bmi;

    cout<<"請輸入身高(cm):";
    cin>>height_in_cm;
    cout<<"請輸入體重(kg):";
    cin>>weight;
    height_in_m=height_in_cm/100;
    bmi=weight/(height_in_m*height_in_m);
    cout<<"你的bmi為:"<<bmi<<endl;

    if(bmi<18.5)
    {
        cout<<"目前狀態:過輕"<<endl;
    }
    else if(bmi<24)
    {
        cout<<"目前狀態:正常範圍"<<endl;
    }
    else if(bmi<27)
    {
        cout<<"目前狀態:過重"<<endl;
    }
    else if(bmi<30)
    {
        cout<<"目前狀態:輕度肥胖"<<endl;
    }
    else if(bmi<35)
    {
        cout<<"目前狀態:中度肥胖"<<endl;
    }
    else
    {
        cout<<"目前狀態:重度肥胖"<<endl;
    }
    return 0;
}
a3137418 commented 9 months ago

include

include

using namespace std; /* https://depart.femh.org.tw/dietary/3OPD/BMI.htm 請輸入身高體重,輸出BMI值 BMI<18.5體重過輕 18.5<=BMI<24體重正常 過重:24≦BMI<27 輕度肥胖:27≦BMI<30 中度肥胖:30≦BMI<35 重度肥胖:BMI≧35

*/ int main() { double 身高; double 體重; double BMI;

cout << "請輸入身高(cm):"; cin >> 身高; cout << "請輸入體重(kg):"; cin >> 體重;

BMI = 體重 / pow((身高/100),2);

if(BMI < 18.5) { cout << "BMI值為:" << BMI << endl; cout << "體重過輕" << endl; } else if (18.5 <= BMI && BMI < 24) { cout << "BMI值為:" << BMI << endl; cout << "體重正常" << endl; } else if (24<= BMI && BMI < 27) { cout << "BMI值為:%.2lf" << BMI << endl; printf("BMI是:%.2lf\n",BMI); cout << "過重" << endl; } else if (27<= BMI && BMI < 30) { cout << "BMI值為:" << BMI << endl; cout << "輕度肥胖" << endl; } else if (30<= BMI && BMI < 35) { cout << "BMI值為:" << BMI << endl; cout << "中度肥胖" << endl; } else if (35<= BMI) { cout << "BMI值為:" << BMI << endl; cout << "重度肥胖" << endl; } }

hughwangyoujun commented 9 months ago

include

using namespace std;

include

int main() { /https://depart.femh.org.tw/dietary/3OPD/BMI.htm 請輸入身高,體重 輸出BMI值 輸出目前狀態 / double height,weight,BMI; cout<<"輸入身高:\n"; cin>>height; cout<<"輸入體重:\n"; height=height/100; cin>>weight; BMI=weight/pow(height,2);

if (BMI<18.5) { cout<<"體重過輕"; } else if (BMI>=18.5&&BMI<=24) { cout<<"正常範圍"; } else if (BMI>=24&&BMI<=27) { cout<<"過重"; } else if(BMI>=27&&BMI<=30) { cout<<"輕度肥胖"; } else if (BMI>=30&&BMI<=35) { cout<<"中度肥胖"; } else { cout<<"You die"; } cout<<"BMI值為:"<<BMI; }

ying0745 commented 9 months ago
#include <iostream>
using namespace std;

int main() {
  double height,weight,bmi;
  cout << "請輸入身高(m):";
  cin >> height;
  cout << "請輸入體重(kg):";
  cin >> weight;

  cout << "bmi值為" << weight/(height*height) << endl;
  bmi = weight / (height * height);
  if(bmi<18.5){
    cout << "體重過輕";
  }else if (bmi<24){
    cout << "正常體重";
    }else{
    cout << "過重";
      }
}
FatAnt93 commented 9 months ago
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
    double height,weight,BMI;
    cout << "請輸入您的身高(cm):";
    cin >> height;
    height = height/100;
    cout << "請輸入您的體重:";
    cin >> weight;
    BMI = weight / pow(height,2.0);
    cout << "您的BMI是:" << BMI <<endl;
    if(BMI<18.5)
    {
        cout << "體重過輕" << endl;
    }
    else if(BMI>=18.5 && BMI <24)
    {
        cout << "正常範圍" << endl;
    }
    else if(BMI>=24 && BMI <27)
    {
        cout << "過重" << endl;
    }
    else if(BMI>=27 && BMI <30)
    {
        cout << "輕度肥胖" << endl;
    }
    else if(BMI>=30 && BMI <35)
    {
        cout << "中度肥胖" << endl;
    }
    else
    {
        cout << "重度肥胖" << endl;
    }
    return 0;
}