logo CodeStepByStep logo

BMI

Language/Type: Java interactive programs parameters

Write a console program in a class named BMI that prompts for user input and calculates 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).

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

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

Have a nice day!

You should break down your program into several methods, each of which helps solve the overall problem. Use the printf method to format real numbers with proper precision.

Complete program: Write an entire program that 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?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.