一下java程序中public double area() {return Math.PI*r*r;} 的Math.PI*r*r是什么意思
publicabstractclassShape{abstractdoublearea();}classCircleextendsShape{doubler;Circle...
public abstract class Shape {
abstract double area();
}
class Circle extends Shape {
double r;
Circle (double r) {
this.r=r;
}
public double area() {
return Math.PI*r*r;
}}
class Cylinder extends Circle {
double h;
Cylinder(double r,double h) {
super(r);
this.h=h;
}
public double area() {
return 1/3.0*Math.PI*r*r;
}}
public class Lisi {
public static void main (String args[]) {
Circle cc1=new Circle(3.0);
Cylinder cy=new Cylinder (2.0,5.0);
System.out.println("The area of circle is"+cc1.area());
System.out.println("The area of cy is"+cy.area());
}
} 展开
abstract double area();
}
class Circle extends Shape {
double r;
Circle (double r) {
this.r=r;
}
public double area() {
return Math.PI*r*r;
}}
class Cylinder extends Circle {
double h;
Cylinder(double r,double h) {
super(r);
this.h=h;
}
public double area() {
return 1/3.0*Math.PI*r*r;
}}
public class Lisi {
public static void main (String args[]) {
Circle cc1=new Circle(3.0);
Cylinder cy=new Cylinder (2.0,5.0);
System.out.println("The area of circle is"+cc1.area());
System.out.println("The area of cy is"+cy.area());
}
} 展开
2个回答
2014-11-03
展开全部
我可能说的不好,不要打我,我也是新手。Math其实就是数值的方法或者说是数字的一些运算什么什么的,不好解释,然后。那个PI 应该是3.14的那个π吧? 取个谐音而已,R是半径之类的
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询