Assignment #48 and BMI Categories
Code
///Name: Tim Gibson
///Period: 6
///Project Name: BMI Categories
///File Name: BMI.java
///Date Finished: 10/8/15
import java.util.Scanner;
public class BMI2
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
double m, kg, bmi, ft, in, hIn, lb;
String category = "error";
System.out.print( "Your height (feet only): " );
ft = keyboard.nextDouble();
System.out.print( "Your height (inches only): " );
in = keyboard.nextDouble();
System.out.print( "Your weight in pounds: " );
lb = keyboard.nextDouble();
hIn = ( 12 * ft ) + in;
m = hIn * .0254;
kg = lb / 2.2046;
bmi = kg / (m*m);
System.out.println( "Your BMI is " + bmi );
if ( bmi < 18.5 )
{
category = "underweight";
}
if ( bmi >= 18.5 && bmi < 25 )
{
category = "Normal Weight";
}
if ( bmi > 24.9 && bmi < 30 )
{
category = "Overweight";
}
if ( bmi >= 30 )
{
category = "Obese";
}
System.out.println( "BMI Category: " + category );
}
}
Picture of the output