java 圆心_JAVA程序帮忙看下把

/*定义类为圆的圆心,再定义圆类并且继承圆心类,再定义圆柱类继承上两个类,最后输出圆心坐标,圆面积之类的数据*/import .*;class Point{private double X,Y;Point(double X,double Y) {this.X=X

/*定义类为圆的圆心,再定义圆类并且继承圆心类,再定义圆柱类继承上两个类,最后输出圆心坐标,圆面积之类的数据*/import .*;class Point{private double X,Y;Point(double X,double Y) {this.X=X;this.Y=Y;}double GetX() {return X;}double GetY() {return Y;}}class Circle extends Point{private double radius;final static double PI=3.1 ;Circle(double radius) {this.radius=radius;}Circle(double X,double Y,double radius) {super(X,Y);this.radius=radius;}double GetArea() {return PI*radius*radius;}double GetPerimeter() {return 2*PI*radius;}}class Cylinder extends Circle{private double height;Cylinder(double height) {this.height=height;}Cylinder(double X,double Y,double radius,double height) { super(X,Y,radius); this.height=height; }double GetHeight() {return height;}double GetBulk() {return GetArea*height;}double GetSurArea() {return GetArea()*2+GetPerimeter()*height;}}public class c_1{public static void main(String[] args)throws IOException{ intln("please enter the coordinate of the center of a circle:"); double X1= ad(); double Y1= ad(); int("please enter the radius of a circle:"); double radius1= ad(); int("please enter the height of a cylinder:"); double height1= ad(); Point p=new Point (X1,Y1); Circle cir=new Circle(radius); Cylinder cyl=new Cylinder(height); intln("the coordinate of the center of circle is:("+p.GetX()+","+p.GetY()+")"); intln("the area of circle is:"+cir.GetArea()); intln("the total surface area of the cylinder is:"+cyl.GetSurArea()); intln("the bulk of cylinder is:"+cyl.GetBulk()); intln("please another enter the coordinate of the center of a circle:"); double X2= ad(); double Y2= ad(); intln("please enter another the height of a cylinder:") double radius2= ad(); intln("please enter another the radius of a circle:"); double height2= ad(); Cylinder ccyl= new Cylinder(double X2,double Y2,double radius2,double height2); intln("the coordinate of the center of circle is:("+p.GetX()+","+p.GetY()+")"); intln("the area of circle is:"+cir.GetArea()); intln("the total surface area of the cylinder is:"+ccyl.GetSurArea()); intln("the bulk of cylinder is:"+ccyl.GetBulk());}}

展开

全部

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值