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’sbody mass index (BMI). Th

ID: 3614300 • Letter: W

Question

Write a program that calculates and displays a person’sbody mass index (BMI). The BMI is often used to determine whether aperson with a sedentary lifestyle is overweight or underweight forhis or her height. A person’s BMI is calculated with thefollowing formula:

           BMI = weight x 703 / height2

where weight is measured in pounds and heightis measured in inches. The program should ask the user to enterhis/her weight and height. The program should display a messageindicating whether the person has optimal weight, is underweight,or is overweight. A sedentary person’s weight is consideredoptimal if his or her BMI is between18.5 and 25. If the BMI is lessthan 18.5, the person is considered underweight. If the BMI valueis greater than 25, the person is considered overweight.

Explanation / Answer

publicstatic void main(String[]args) { // input double weight= JOptionPane.showInputDialog("Enter your weight: ", 0.0); double height= JOptionPane.showInputDialog("Enter your height: ", 0.0); //calculations double bmi= weight * 703 / height/ height; Stringoutput; if(bmi< 18.5) { output = "You areunderweight."; } else if(bmi > 25) { output = "You areoverweight"; } else { output = "You have optimalweight."; } // output JOptionPane.showMessageDialog(null, output); }
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