> 其他 >
用java 定义一个圆类,再创建一个柱体类,求以圆形为底的柱体体积.
人气:184 ℃ 时间:2020-04-11 23:04:55
解答
class Circle
{
double r;

}
class Volum extends Circle{

double height;//柱体高度
double volu( double r, double height)
{this.height=height;
super.r=r;
return Math.PI*r*r*height;}//计算体积
}

public class test{
public static void main(String args[])
{
Volum c=new Volum();
System.out.println("圆柱体的体积为: "+c.volu(1,5));
}

}
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版