Write a Java program to compute body mass index (BMI).
Test Data
Input weight in pounds: 452
Input height in inches: 72
Expected Output:
Body Mass Index is 61.30159143458721
import java.util.Scanner; class RicMain { public static void main(String args[]) { //formula for body mass index: BMI = (730) * (Weight(w)(in pounds)/height * height(h)(in inches)) Scanner hw = new Scanner(System.in); System.out.print("Enter your height in pounds: "); double h = hw.nextDouble(); System.out.print("Enter your weight in inches: "); double w = hw.nextDouble(); double bmi = ((730 * w) / (h * h)); System.out.println("Your body mass index (BMI) is: " + bmi); } }
There is a problem. When I enter the following after executing the code:
Enter your height in pounds: 452
Enter your weight in inches: 72
Your body mass index (BMI) is: 0.257263685488292 <------This is wrong. What an I doing wrong?