用JAVA编写程序,输入半径和高,通过圆柱的底面积公式和体积公式来计算圆柱的底面积和体积!
eg:
代码:
import java.util.Scanner;
public class bb{
public static void main(String[] args){
final double PI = 3.14159;
System.out.print("please input radius and height:");
Scanner input = new Scanner(System.in);
double radius = input.nextDouble();
double height = input.nextDouble();
double area = PI * radius * radius;
double volumn = area * height;
System.out.println("The area is "+area);
System.out.println("The volumn is "+volumn);
}
}
结果:
时间: 2024-11-05 02:18:31