/**
* 计算机圆柱体的体积。
* 读入圆柱体的半径和高,并使用下列公式计算圆柱体的体积:
* 使用下列公式计算圆柱的体积:
* 面积 = 半径 * 半径 * PI;
* 体积 = 面积 * 高。
* 下面是一个运行示例:
* —————————————————————————————————————————————————————
* | Enter the radius and length of a cylinder: 5.5 12 |
* | The area is: 95.0331 |
* | The volume is: 1140.4 |
* —————————————————————————————————————————————————————
*/
package Test;
import java.util.Scanner;
public class T22 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter the radius and length of a cylinder: ");
double radius = input.nextDouble();
double height = input.nextDouble();
double area = radius * radius * Math.PI;
double volume = area * height;
System.out.println("The area is: " + area);
System.out.println("The volume is: " + volume);
}
}
第2章:计算机圆柱体的体积
最新推荐文章于 2022-05-12 16:12:19 发布