Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that calculates and displays a person\'s body mass index (BMI).

ID: 3628995 • Letter: W

Question

Write a program that calculates 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 under-weight for his or her height. A person's BMI is calculated with the following formula:
BMI = weight x 703 / height^2
Where weight is measured in pounds and height is measured in inches. The program should display a message indicating whether the person has optimal weight, is underweight, or is overweight. A sedentary person's 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.

Explanation / Answer

import java.util.Scanner; public class BMI { public static void main(String args[ ]) { Scanner scan = new Scanner(System.in); String value; System.out.println("Enter your weight in kg: "); double weight = scan.nextDouble(); System.out.println("Enter your height in meter: " ); double height = scan.nextDouble(); double BMI = weight/(height*height);// Computes users BMI if (BMI < 18.5) { value = "underweight";} else if (BMI > 25) {value = "overweight";} else {value = "optimal";} System.out.printf("Your Body Mass Index is: %.2f and it is %s.",BMI,value); System.out.println(); } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote