用java 定义一个圆类,再创建一个柱体类,求以圆形为底的柱体体积.
网友回答
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));
}}