本題主要是熟悉JAVA操作
import java.util.Scanner;
public class Main{
public static void main(String[] arge){
Scanner scann=new Scanner(System.in);
double wei=scann.nextDouble();
double hei=scann.nextDouble();
double num=wei/Math.pow(hei,2);
System.out.println(String.format("%.1f",num));
if(num>25)
System.out.println("PANG");
else
System.out.println("Hai Xing");
}
}
上面的關於浮點型保留位數的問題可以參考下面的博客
傳送門: