logo CodeStepByStep logo

BMI

Related Links:
Author: Marty Stepp (on 2016/06/20)

Write a complete C++ program to calculate 2 people's body mass index (BMI), using the following formula:

BMI = weight / height2 * 703

The BMI rating groups each person into one of the following four categories:

BMI Category
below 18.5 class 1
18.5 - 24.9 class 2
25.0 - 29.9 class 3
30.0 and up class 4

Match the following example output:

This program reads data for two people
and computes their body mass index (BMI).

Enter Person 1's information:
height (in inches)? 70.0
weight (in pounds)? 194.25
BMI = 27.8689, class 3

Enter Person 2's information:
height (in inches)? 62.5
weight (in pounds)? 130.5
BMI = 23.4858, class 2

BMI difference = 4.3831

You should break down your program into several functions, each of which helps solve the overall problem.

Type your C++ solution code here:


This problem asks for a complete program. This should essentially be contents you could put into a file and run outside of CodeStepByStep.

You must log in before you can solve this problem.


Log In

Need help?

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.

© Marty Stepp, all rights reserved.