Assignment # 48 and BMI Categories
Code
/// Name: Tommy Oyuntseren
/// Period: 7
/// Program Name: BMICategories
/// File Name: BMICategories.java
/// Date: 11/17/2015
import java.util.Scanner;
public class BMICategories
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
double m, kg, bmi;
String cat = "-";
System.out.print( "Your height in m: " );
m = keyboard.nextDouble();
System.out.println();
System.out.print("Your weight in kg: ");
kg = keyboard.nextDouble();
bmi = kg / (m*m);
System.out.println();
System.out.println( "Your BMI is " + bmi );
System.out.println();
if (bmi < 15) cat = "very severely underweight";
if (bmi >= 15 & bmi <= 16) cat = "severely underweight";
if (bmi >= 16 & bmi <= 18.4) cat = "underweight";
if (bmi >= 18.4 & bmi <= 24.9) cat = "normal weight";
if (bmi >= 24.9 & bmi <= 29.9) cat = "overweight";
if (bmi >= 29.9 & bmi <= 34.9) cat = "moderately obese";
if (bmi >= 34.9 & bmi <= 39.9) cat = "severely obese";
if (bmi >= 40) cat = "very severely obese";
System.out.println("BMI Category: "+cat);
}
}
Picture of the output