用java 定义一个圆类,再创建一个柱体类,求以圆形为底的柱体体积.

首页/题库/435℃/2024-07-08 21:45:48

优质解答:

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));

}

}

我来回答修改/报错/举报内容!

猜你喜欢

一个神奇的在线题库网,分享各类考试题库、题目资料与资料答案、在线搜题与练习等!
本网站部分内容、图文来自于网络,如有侵犯您的合法权益,请及时与我们联系,我们将第一时间安排核实及删除!
Copyright © 2021-2024 315题库 All Rights Reserved