设为首页 加入收藏

TOP

java小代码计算矩形的面积和周长
2014-11-23 21:52:19 】 浏览:243
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实现动态特性的关键..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目