创建一个矩形类,包含两个成员变量width和 height,方法area和circle计算面积和周长

更新时间:2023-06-19 21:25:02 阅读: 评论:0

创建一个矩形类,包含两个成员变量width和 height,方法area和circle计算面积和周长
添加两个属性width、height,分别表示宽度和高度,添加计算矩形的周长和面积的方法。测试输出一个矩形的周长和面积。
public class Rectangle {
    private double recWidth;
    private double recHeight;
    private double recGirth;
    private double recArea;
   
    public void  getGirth(){
      recGirth=2*(recWidth+recHeight);
    }
     
      public void getArea(){
      recArea=recWidth*recHeight;
    }
   
    public void showRec(){
      System.out.println("周长:"+recGirth);授权管理
阴道炎用什么药治疗
      System.out.println("面积:"+recArea);
    }
   
    public Rectangle(){
      Scanner src=new Scanner(System.in);
      System.out.print("请输入recWidth和Height:");
      int Int();
      int Int();
公众号动图      Width=pass;
    Height=dass;
璞读音
    }
   
    public static void main(String[] args){
        Rectangle sc=new Rectangle();
做手工的作文
房屋建筑工程        sc.getGirth();
心理相容
          sc.getArea();
        sc.showRec();
个税计算
    }
}
   

本文发布于:2023-06-19 21:25:02,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/993702.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:矩形   周长   面积   添加   计算   高度
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图