设为首页 加入收藏

TOP

求Box体积和面积的java小程序
2014-11-23 21:52:19 来源: 作者: 【 】 浏览:59
Tags:Box 体积 面积 java 程序

  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();


  }


  }


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇将Java代码打包为exe文件 下一篇java小代码计算矩形的面积和周长

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: