搜索 | 会员  
Box体积和面积的java小程序
来源: 中国IT实验室    作者:网友  日期:2009/12/16  类别:编程语言  主题:Java  编辑:德仔
class Box{   double width;   double height;   double depth;  
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();

  }

  }

德仔网尊重行业规范,每篇文章都注明有明确的作者和来源;德仔网的原创文章,请转载时务必注明文章作者和来源:德仔网;
头条那些事
大家在关注
广告那些事
我们的推荐
也许感兴趣的
干货