可能是符合题意版
public class BMICalculator{
public static void main(String[] args){
double weight = Double.parseDouble(args[0]);
int check_1=(int)weight;
//System.out.println(weight+" "+check_1+" "+(weight-check_1));
double height= Double.parseDouble(args[1]);
System.out.println(weight+" "+height);
int check_2=(int)height;
double BMI=weight/height/height;
String str = String.format("%.2f",BMI);
double print = Double.parseDouble(str);
if(weight-check_1==0)
System.out.println("Your weight: "+check_1+" kg");
else if(weight-check_1!=0)
System.out.println("Your weight: "+weight+" kg");
if(weight-check_2!=0)
System.out.println("Your height: "+height+" m");
else if(weight-check_2==0)
System.out.println("Your height: "+check_2+" m");
System.out.println("Your BMI: "+print);
System.out.print("You are in the ");
if(BMI<18.5)
System.out.print("Underweight range");
else if(BMI>=18.5&&BMI<24.9)
System.out.print("Normal range");
else if(BMI>=25&&BMI<=29.9)
System.out.print("Overweight range");
else if(BMI>=30)
System.out.print("Obese range");
}
}
public class BMICalculator{
public static void main(String[] args){
int weight=Integer.parseInt(args[0]);
int Height= Integer.parseInt(args[1]);
double height=(double)Height/100;
double BMI=weight/height/height;
System.out.printf("Your weight: %d kg\n",weight);
System.out.printf("Your height: %.2f m\n",height);
System.out.printf("Your BMI: %.2f \n",BMI);
System.out.print("You are in the ");
if(BMI<18.5)
System.out.print("Underweight range.");
else if(BMI>=18.5&&BMI<=24.9)
System.out.print("Normal range");
else if(BMI>=25&&BMI<=29.9)
System.out.print("Overweight range");
else if(BMI>=30)
System.out.print("Obese range");
else
System.out.println("ERROR input");
}
}