package practice;
import java.util.Scanner;
public class Yuan {
public static void main(String[] args) {
System.out.println("The area is "+area()); //直接调用函数
}
public static double area(){ //定义函数area()计算圆面积
System.out.println("Please input r!");
Scanner m=new Scanner(System.in);
double r=m.nextDouble();
double s= r*r*Math.PI;
return s;
}
}
如果想把面积的值限定为5位小数 那应该怎么修改?求指点
|
|