package nameyu;import java.util.Scanner;public class Test { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner input=new Scanner(System.in); System.out.print("Enter weight in pounds:"); double weight=input.nextDouble(); System.out.print("Enter feet:"); double feet=input.nextDouble(); System.out.print("Enter inches"); double inches=input.nextDouble(); final int FEET_PER_INCHES =12; final double KILOGRAM_PERPOUND=0.45359237; final double METERS_PER_INCH=0.0254; double weightInKilograms=weight*KILOGRAM_PERPOUND; double heightInMeters=(double)(feet*12+inches)*0.0254; double BMI=weightInKilograms/(heightInMeters*heightInMeters); System.out.println("BMI is "+BMI); if(BMI<18.5) System.out.println("underweight"); else if(BMI<25) System.out.println("normal"); else if(BMI<30) System.out.println("overweight"); else System.out.println("obese"); } }
|