Assignment #26
Code
///Name: Cody Swain
///Period: 6
///Project Name: BMICalculator
///File Name: BMICalculator.java
///Date: 10/2/15
import java.util.Scanner;
public class BMICalculator
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int a;
double m, kg, ft, lbs, bmi;
System.out.print( "Do you use meters or feet (1 for m, 2 for ft)? " );
a = keyboard.nextInt();
if (a == 1){
System.out.print( "Your height in meters: ");
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 (a == 2){
System.out.print( "Your height in feet: " );
ft = keyboard.nextInt();
System.out.print( "Your weight in lbs: " );
lbs = keyboard.nextDouble();
bmi = (ft*.3048) / (lbs*.4536);
System.out.println( "Your BMI is " + bmi );
}
}
}
Picture of the output