as12350991 2020-10-13 21:55 采纳率: 50%
浏览 62
已采纳

这道题应该如何做。有大神帮忙么?

Overview

Write a program to calculate the user’s body mass index (BMI).
Directions
A person’s body mass index (BMI) is calculated using their height and weight. The formula for BMI is:

BMI = kg / m2

Where kg is the person’s mass in kilograms, and m2 is their height in metres squared.
Write a program to calculate a person’s BMI. Your program should first ask the user to enter their height in feet and inches, then their weight in pounds. Your program should then use the data to calculate the person’s BMI. Your program should also display the person’s height and weight in metres and kilograms. There are 12 inches in a foot, 3.28084 feet in a metre, and 2.20462 pounds in a kilogram.

The listing below shows an example of what the input and output for this program might look like. Input by the user is listed in blue.

What is your height?
Feet: 5
Inches: 10
What is your weight (lbs)? 160

Height (m): 1.778
Weight (kg): 72.5749
BMI: 22.9574
用C++

  • 写回答

2条回答 默认 最新

  • threenewbee 2020-10-13 23:56
    关注
    #include <iostream>
    using namespace std;
    int main()
    {
    float feet, inches, weight, m, kg, bmi;
    cout << "Feet:";
    cin >> feet;
    cout << "Inches:";
    cin >> inches;
    cout << "What is your weight (lbs)?";
    cin >> weight;
    m = (feet + inches / 12.0) / 3.28084;
    cout << "Height (m): " << m << endl;
    kg = weight / 2.20462;
    cout << "Weight (kg):" << kg << endl;
    bmi = kg / m / m;
    cout << "BMI:" << bmi << endl;
    return 0;
    }
    

    Feet:5
    Inches:10
    What is your weight (lbs)?160
    Height (m): 1.778
    Weight (kg):72.5749
    BMI:22.9574

    问题解决的话,请点采纳

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度