import java.util.Scanner;
class Box {
int length;
int width;
int height;
void setBox(int l,int w,int h){
length=l;
width=w;
height=h;
}
int volume(){
int V=(int)(length*width*height);
return V;
}
public static void main(String[] args) {
Box b=new Box();
Scanner reader = new Scanner(System.in);
System.out.println("请长方体输入长宽高:");
b.length=reader.nextInt();
b.width=reader.nextInt();
b.height=reader.nextInt();
System.out.println(b.volume());
}
}
Java类与方法的练习(求长方体的体积)
最新推荐文章于 2024-09-24 20:40:44 发布