JAVA语言程序设计目的,JAVA小程序求助目的:掌握JAVA语言程序设计的基本要求内容: 爱问知识人...

给你个示例参考:

import java。util。ArrayList;

import java。util。List;

import java。util。Scanner;

public class CuboidDemo {

public static void main(String[] args) {

intln("请输入3个长方体的长、宽、高: ");

int i = 1;

int length = 0 ;

int width = 0;

int height = 0 ;

List list = new ArrayList();

Scanner input = new Scanner( );

try{

while(true){

intln("第" + i + "个长方体: ");

int("长= ");

length = xtInt();

int("宽= ");

width = xtInt();

int("高= ");

height = xtInt();

intln();

Cuboid cuboid = new Cuboid(length,width,height);

d(cuboid);

i++;

if(i>3){

break;

}

}

}catch (Exception e) {

intln("输入有错!");

}

for(int n = 0; n < ze() ; n++){

intln("第" + (n+1) + "个长方体 参数: " + t(n));

intln("第" + (n+1) + "个长方体 体积: " + t(n)。

getBulk());

}

}

}

class Cuboid {

private int length = 0 ;

private int width = 0;

private int height = 0 ;

public Cuboid(){

}

public Cuboid(int length,int width,int height){

this。

length = length;

this。width = width;

this。

height = height;

}

public int getBulk(){

return length*width*height;

}

public String toString() {

return "[length=" + length + ", width=" + width + ", height="

+ height + "]";

}

}

全部

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值