java中,求圆的面积 圆柱的面积和体积,求圆柱的面积时调用圆的面积的求法
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/08/31 21:41:17
java中,求圆的面积 圆柱的面积和体积,求圆柱的面积时调用圆的面积的求法
public class GetColumnInfo {
public static void main(String[] args) {
double circleArea = getCirclSquare(10);//圆的面积
double columnVolumn = getColumnVolumn(10,2);//圆柱的体积
double columnArea = getColumnArea(10,2);//圆柱的表面积
}
//根据半径返回圆的面积
public static double getCirclSquare(double radius){
double square = Math.PI * radius * radius;
return square;
}
//根据半径和高返回圆柱的体积
public static double getColumnVolumn(double radius,double height){
double square = getCirclSquare(radius);//先得到圆柱的横截面积
double columnVolumn = square * height;
return columnVolumn;
}
//根据半径和高返回圆柱的表面积
public static double getColumnArea(double radius,double height){
double width = 2 * Math.PI * radius; //横截面的周长
double upArea = width * height;
double bottomArea = getCirclSquare(radius);
double columnArea = upArea + 2 * bottomArea;
return columnArea;
}
}
public static void main(String[] args) {
double circleArea = getCirclSquare(10);//圆的面积
double columnVolumn = getColumnVolumn(10,2);//圆柱的体积
double columnArea = getColumnArea(10,2);//圆柱的表面积
}
//根据半径返回圆的面积
public static double getCirclSquare(double radius){
double square = Math.PI * radius * radius;
return square;
}
//根据半径和高返回圆柱的体积
public static double getColumnVolumn(double radius,double height){
double square = getCirclSquare(radius);//先得到圆柱的横截面积
double columnVolumn = square * height;
return columnVolumn;
}
//根据半径和高返回圆柱的表面积
public static double getColumnArea(double radius,double height){
double width = 2 * Math.PI * radius; //横截面的周长
double upArea = width * height;
double bottomArea = getCirclSquare(radius);
double columnArea = upArea + 2 * bottomArea;
return columnArea;
}
}