Question: Revise Listing 3.4, ComputeAndInterpretBMI.java, to let the user enter weight, feet, and inches. For example, if a person is 5 feet and 10 inches, you

Revise Listing 3.4, ComputeAndInterpretBMI.java, to let the user enter weight, feet, and inches. For example, if a person is 5 feet and 10 inches, you will enter 5 for feet and 10 for inches. Here is a sample run:

Enter weight in pounds: 140 feet: 5 Enter inches: 10 -Enter BMI

Listing 3.4

is 20.087702275404553 Normal JEnter JEnter 1 import java.util.Scanner; 2 3 public class

Enter weight in pounds: 140 feet: 5 Enter inches: 10 -Enter BMI is 20.087702275404553 Normal JEnter JEnter 1 import java.util.Scanner; 2 3 public class ComputeAndInterpretBMI { public static void main(String[] args) { Scanner input = new Scanner (System.in); 5 // Prompt the user to enter weight in pounds System.out.print("Enter weight in pounds: "); double weight = input.nextDouble(); 10 // Prompt the user to enter height in inches System.out.print("Enter height in inches: "); double height = input.nextDouble(); 11 12 13 14 15 16 17 final double KILOGRAMS_PER_POUND = 0.45359237; // Constant final double METERS_PER_INCH = 0.0254; // Constant 18 19 20 21 22 23 24 25 26 // Compute BMI double weightInKilograms = weight * KILOGRAMS_PER_POUND; double heightInMeters = height* METERS_PER_INCH; double bmi = weightInKilograms / (heightInMeters * heightInMeters); // Display result System.out.println("BMI is " + bmi); if (bmi < 18.5) System.out.println("Underweight"); else if (bmi < 25) System.out.println("Normal"); else if (bmi < 30) System.out.println("Overweight"); else System.out.println("Obese"); 27 28 29 30 31 32 33 34 35 } Enter weight in pounds: 146 Jerter Enter height in inches: 70 PJesser BMI is 20.948603801493316 Normal line# weight height weightInkilograms heightInMeters bmi output 146 13 70 19 66.22448602 20 1.778 21 20.9486 25 BMI is 20.95 31 Normal

Step by Step Solution

3.42 Rating (168 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Health application BMI Program plan Prompt the user to enter weight feet and inches Calculate the BM... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java Programming Questions!