Assignemnt #44 Two More Questions
Code
///Name: JJ Deng
///Period: 6
///Program name: BMI Categories
///File name: BMICategories.java
///Date finished: 11/28/15
import java.util.Scanner;
public class BMICategories
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
double m, kg, bmi;
String res="";
System.out.print("Your height in meters: ");
m = keyboard.nextDouble();
System.out.print("Your weight in kilograms: ");
kg = keyboard.nextDouble();
System.out.println("");
bmi = kg/(m*m);
if (bmi < 15.0)
{
res = "very severely underweight";
}
if (bmi >= 15.0 && bmi <= 16.0)
{
res = "severely underweight";
}
if (bmi >= 16.1 && bmi <= 18.4)
{
res = "underweight";
}
else if (bmi >= 18.5 && bmi <= 24.9)
{
res = "normal weight";
}
if (bmi >= 25.0 && bmi <= 29.9)
{
res = "overweight";
}
if (bmi >= 30.0 && bmi <= 34.9)
{
res = "moderately obese";
}
if (bmi >= 35.0 && bmi <= 39.9)
{
res = "severely obese";
}
if (bmi >= 40.0 )
{
res = "very severly obese";
}
System.out.println("Your BMI: " + bmi );
System.out.println("BMI Category: " + res );
}
}
Picture of the output