Programming Assignment #47
Code
/// Name: Dylan Sleeper
/// Period: 6
/// Program Name: Else and If
/// File Name: questions.java
/// Date Finished: 10/22/2015
import java.util.Scanner;
public class BmiInfo
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
double m, kg, bmi;
System.out.print( "Your height in m: " );
m = keyboard.nextDouble();
System.out.print( "Your weight in kg: " );
kg = keyboard.nextDouble();
bmi = kg / (m*m);
System.out.println( "Your BMI is " + bmi );
if(bmi <= 15.0){
System.out.println("BMI category: Very severly underwieght");
}
else if(bmi <= 16.0){
System.out.println("BMI category: Severly underweight");
}
else if(bmi <= 18.4){
System.out.println("BMI category: Underweight");
}
else if(bmi <= 24.9){
System.out.println("BMI category: Normal weight");
}
else if(bmi <= 29.9){
System.out.println("BMI category: Overweight");
}
else if(bmi <= 34.9){
System.out.println("BMI category: Moderately obese");
}
else if(bmi <= 39.9){
System.out.println("BMI category: Severely obese");
}
else if(bmi <= 40.0){
System.out.println("BMI category: Morbidly obese");
}
}
}
Outputs