当前所在位置:珠峰网资料 >> 计算机 >> 计算机等级考试 >> 正文
计算机二级辅导:求Box体积和面积的java小程序
发布时间:2010/3/13 9:31:01 来源:城市学习网 编辑:MOON
  class Box{
  double width;
  double height;
  double depth;
  public Box(double w,double h,double d){
  width=w;
  height=h;
  depth=d;
  }
  void getBox(){
  System.out.println("The width of Box is :"+width);
  System.out.println("the heigth of Box is :"+height);
  System.out.println("The depth of Box is :"+depth);
  }
  void volume(){
  System.out.println("The volume of Box is:"+(width*height*depth));
  }
  void area(){
  System.out.println("The area of Box is :"+2*(width*height+width*depth+height*depth));
  }
  }
  public class BoxDemo {
  public static void main(String args){
  Box box=new Box(5,2,5);
  box.getBox();
  box.volume();
  box.area();
  }
  }
广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved