当前位置: 首页> 汽车> 维修 > 互联网公司排名500强_创鑫时代广告公司简介_引流推广平台软件_快速将网站seo

互联网公司排名500强_创鑫时代广告公司简介_引流推广平台软件_快速将网站seo

时间:2025/8/12 2:17:37来源:https://blog.csdn.net/2301_81591020/article/details/144934493 浏览次数: 0次
互联网公司排名500强_创鑫时代广告公司简介_引流推广平台软件_快速将网站seo

设计一个矩形类Rectangle,包含私有的数据成员宽度(Width)和高度(Height);公有的方法double getArea()返回矩形的面积,公有的方法double getPerimeter()返回矩形的周长。

例如:

测试Result
Rectangle rect=new Rectangle(8,5);
System.out.printf("The Area is %.2f,Perimeter is %.2f\n", rect.getArea(),rect.getPerimeter());
The Area is 40.00,Perimeter is 26.00

 

class Rectangle{private double Width;private double Height;public Rectangle(double width, double height) {Width = width;Height = height;}public double getArea() {return Width * Height;}public double getPerimeter(){return (Width + Height) * 2;}
}
public class Test{public static void main(String[] args) {Rectangle rect=new Rectangle(8,5);System.out.printf("The Area is %.2f,Perimeter is %.2f\n", rect.getArea(),rect.getPerimeter());}
}

关键字:互联网公司排名500强_创鑫时代广告公司简介_引流推广平台软件_快速将网站seo

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: