1、编写一个长方体类,求长方体的体积和表面积(JAVA编程)

问题描述:

1、编写一个长方体类,求长方体的体积和表面积(JAVA编程)

package 长方体;
public class Rectangle {
//构造
public Rectangle(){}
//体积
public static double cubage(double a,double b,double c){
double cube = a*b*c;
return cube;
}
//表面积
public static double area(double a,double b,double c){
double surface=2*(a*b+a*c+b*c);
return surface;
}
//测试
public static void main(String[] args) {
double cube;
double surface;
cube = cubage(1,2,3);
surface = area(1,2,3);
System.out.println("长方体体积:"+cube);
System.out.println("长方体表面积:"+surface);
}
}