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++