In Java Write a program that produces the output shown below. Output Enter your weight in pounds:200 Enter your height in feet followed by a space then additional inches:5 7 Your BMI is 31.38992486697179 Your risk category is Obese. |
||
import java.util.Scanner; public class BMICalculation { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter your weight in pounds: "); double weight = in.nextDouble(); System.out.print("Enter your height in feet followed by a space then additional inches:"); double height = in.nextDouble() * 12 + in.nextDouble(); double bmi = (weight * 703) / (height * height); String category; if (bmi < 18.5) { category = "Underweight"; } else if (bmi < 25) { category = "Normal"; } else if (bmi < 30) { category = "Overweight"; } else { category = "Obese"; } System.out.printf("Your BMI is %f Your risk category is %s.\n", bmi, category); } }
Get Answers For Free
Most questions answered within 1 hours.