设为首页 加入收藏

TOP

java小代码计算矩形的面积和周长
2014-11-23 21:52:19 来源: 作者: 【 】 浏览:53
Tags:java 代码 计算 矩形 面积 周长

  class Ractangle {


  double width;


  double height;


  public Ractangle(double w,double h){


  width=w;


  height=h;


  }


  void Area(){


  System.out.println( width*height);


  }


  void perimeter(){


  System.out.println(2*(width+height));


  }


  }


  public class RectangleDemo {


  public static void main(String args[]){


  Ractangle ractangle=new Ractangle(40,50);


  ractangle.Area();


  ractangle.perimeter();


  }


  }


  编辑特别推荐:


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇求Box体积和面积的java小程序 下一篇JAVA技巧:OSGi实现动态特性的关键..

评论

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