箱子体积
程序员文章站
2022-05-21 08:14:36
...
import java.util.Scanner;
public class 体积 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
箱子的体积 v=new 箱子的体积(sc.nextDouble(),sc.nextDouble(),sc.nextDouble());
v.output();
sc.close();
}
}
public class 箱子的体积 {
double height;
double width;
double length;
public 箱子的体积(double height,double width,double length) {
this.height=height;
this.width=width;
this.length=length;
}
double getVolum() {
return (height*width*length);
}
void output() {
System.out.println("箱子的高宽长为: ");
System.out.println("高度为:"+height);
System.out.println("宽度为:"+width);
System.out.println("长度为:"+length);
double v=getVolum();
System.out.println("箱子的体积为:"+v);
}
}
上一篇: 互联网培训和付费圈子的问题介绍