題目規定PI的值
不能使用Math類的PI來計算
而且對于OJ來說,
System.out.printf("%.3f\r\n",volume);
要加\n
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sr=new Scanner(System.in);
while(sr.hasNext()){
double r = sr.nextDouble();
double volume = Volume(r);
System.out.printf("%.3f\r\n",volume);
}
}
public static double Volume(double r){
double Volume = 0.0;
double PI = 3.1415927;
Volume = 4.0/3.0 * PI * Math.pow(r,3);
return Volume;
}
}