Question: Write a program that calculates and displays a persons body mass index (BMI) in the main method of class Answer . A persons BMI is
Write a program that calculates and displays a persons body mass index (BMI) in the main method of class Answer.
A persons BMI is calculated with the following formula: BMI = Weight * 703 / (Height*Height), where weight is measured in pounds and height is measured in inches.
The program should first ask the user to enter the weight showing the message "Enter weight in pounds:".
Once the user enters the weight, the program should ask the user to enter the height showing the message "Enter height in inches:".
Once the user enters the height, the program should display one of the three messages, "Optimal weight!", "Underweight!", or "Overweight!" indicating whether the person has optimal weight, is underweight, or is overweight.
- A sedentary persons weight is considered optimal if his or her BMI is between 18.5 and 25.
- If the BMI is less than 18.5, the person is considered underweight.
- If the BMI value is greater than 25, the person is considered overweight.
Note: After each output to the console, there should be a newline character.
We have this till now:
public class Answer{
public static void main(String[] arg) { //TODO: Write your code here. } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
