Assignment # 26 and BMI Calculator
Code
/// Name: Tommy Oyuntseren
/// Period: 7
/// Program Name: BMICalculator
/// File Name: BMICalculator.java
/// Date Finished: 10/13/15
import java.util.Scanner;
public class BMICalculator
{
final static float feetToMeters = 0.3048f;
final static float inchesToMeters = 0.0254f;
final static float poundsToKg = 0.453592f;
public static void main( String[] args )
{
float m, kg, bmi, pounds;
int inch,feet;
Scanner keyboard = new Scanner(System.in);
System.out.println();
System.out.print( "Your height in feet only: " );
feet = keyboard.nextInt();
System.out.println();
System.out.print( "Your height in inches only: " );
inch = keyboard.nextInt();
System.out.println();
System.out.print( "Your weight in pounds: " );
pounds = keyboard.nextFloat();
m = feet*feetToMeters + inch*inchesToMeters;
kg = pounds*poundsToKg;
bmi = kg / (m*m);
System.out.println();
System.out.println( "Your BMI is " + bmi );
}
}
Picture of the output