用java编写圆台的体积
- 提问者网友:十年饮冰
- 2021-04-11 21:46
- 五星知识达人网友:迟山
- 2021-04-11 23:05
- 1楼网友:天凉才是好个秋
- 2021-04-12 00:15
class Upcircle {double ra; public Upcircle(double r1) {ra=r1;} pulblic double getRu() {return ra;} pulblic double getAreaUp() {return 3.14*ra*ra; } }
class Downcircle {double rb; public Downcircle(double r2) {rb=r2;} public double getRd() {return rb;} public double getAreaDown() {return 3.14*rb*rb;} }
class CircleT {Upcircle c1; Downcircle c2; double h; public CircleT(Upcircle circle1, Downcircle circle2,double h) { this.c1=circle1; this.c2=circle2; this.h=h; } public double getTiji() {double volume; volume=(c1.getAreaUp()+c2.getAreaDown()+3.14*c1.getRu()*c2.getRd())*h/3.0; return volume; } } class liubin {public static void main(String args[]) {Upcircle circle1=new Upcircle(10); Downcircle circle2=new Downcircle(20); CircleT circular=new CircleT (circle1,circle2,10); System.out.println("圆台的体积:"+circular.getTiji()); }}
正方形一边上任一点到这个正方形两条对角线的 |
阴历怎么看 ? |