Assignemnt #48
Code
/// Name: Holden Ganch
/// Period: 7
/// Program Name: Fourty Eighth Program
/// File Name: BMI.java
/// Date Finished: 11/6/2015
import java.util.Scanner;
class BMI {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
double w, h, bmi;
String category;
category = "";
System.out.print("Your height in inches: ");
h = keyboard.nextDouble();
System.out.print("Your weight in pounds: ");
w = keyboard.nextDouble();
System.out.println("");
bmi = (h * h) / w ;
System.out.println("Your BMI is " + bmi);
if ( bmi < 15.0 )
{
category = "very severely underweight";
}
if ( bmi >= 15.0 && bmi <= 16.0 )
{
category = "severely underweight";
}
if ( bmi >= 16.1 && bmi <= 18.4 )
{
category = "underweight";
}
if ( bmi >= 18.5 && bmi <= 24.9 )
{
category = "normal weight";
}
if ( bmi >= 25.0 && bmi <= 29.9 )
{
category = "overweight";
}
if ( bmi >= 30.0 && bmi <= 34.9 )
{
category = "moderately obese";
}
if ( bmi >= 35.0 && bmi <= 39.9 )
{
category = "severely obese";
}
if ( bmi >= 40.0 )
{
category = "very severely obese";
}
System.out.println("BMI Category: " + category);
}
}
Picture of the output