Starting from:
$30

$24

Assignment: Body Mass Index Solution

Write a program that reads names, weights, and heights from BMI.dat (do not change the file name).

Use the information to calculate and displays a person’s body mass index (BMI). The BMI is often used

to determine whether a person with a sedentary lifestyle is overweight or underweight for his or her height.

A person’s BMI is calculated with the following formula:




BMI = weight * 703 / height ^2, where weight is measured in pounds and height is measured in inches.




The file format is: 'name', 'weightInKG', 'heightInCM'




Steps:

Read the name, weight, and height for 4 people from the file

Convert the weights in the file to pounds (Note: 1 kilogram = 2.2 pounds)

Convert the heights in the file to inches (Note: 1 cm = 0.39 inches)

Display the person's name, their calculated BMI, and whether they are considered

overweight, optimal, or underweight

* overweight is above 25 BMI

* optimal is between 18.5 and 25

* underweight is below 18.5

Validate input: heights and weights from the file MUST be greater than 0.




Modules:

More products