The formula for calculating BMI is:
BMI = (weightInPounds * 703) / (heightInInches * heightInInches)
Your application should prompt the user to enter a weight (in pounds) and height (feet first, and then inches). Your application must convert the entered feet and inches to total height in inches, calculate the BMI and display the result with 2 decimal digits. If you used the variable BMI to store the result of you calculation, you can output it with this statement:
print("BMI = %.2f" % BMI)
The next chapter provides a lot more information on how to format output values.
Here is a sample test run of the application (your implementation may use different output formatting):
BMI (body mass index) calculator
Enter weight (in lbs.)
180
Enter height (feet first, then inches)
feet 5
inches 10
BMI = 25.82
print("BMI (body mass index) calculator") print("Enter weight (in lbs.)") weightInPounds = float(input()) print("Enter height (feet first, then inches)") feet = float(input("feet ")) inches = float(input("inches ")) heightInInches = feet * 12 + inches BMI = (weightInPounds * 703) / (heightInInches * heightInInches) print("BMI = %.2f" % BMI)
Get Answers For Free
Most questions answered within 1 hours.