liang183 发表于 2016-12-24 15:31:14

java小程序实现医疗应用程序:BMI

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");    }    }   
页: [1]
查看完整版本: java小程序实现医疗应用程序:BMI