JAVA编程错误: 在类 Circle 中找不到主方法, 请将主方法定义为: public static void main(String[] args)
publicclassCircle{privatefloatr=50;doubleπ=3.14;doubles;doublez;Circle(){}publicCircl...
public class Circle {
private float r=50;
double π=3.14;
double s;
double z;
Circle() {
}
public Circle(float r,double s,double z){
this.r=r;
this.s=s;
this.z=z;
}
public Circle(double s2) {
// TODO Auto-generated constructor stub
}
double getArea(){
return r*r*π;
}
double getPerimeter(){
return 2*π*r;
}
void show() { System.out.println("圆的半径Radius=" + r + ",圆的周长Perimeter=" + this.getPerimeter() + ",圆的面积Area=" + this.getArea());
}
}
class Cylinder extends Circle{
private double h=20;
Cylinder(double r, double h){
super(r);
}
double getVolume(){ super. getArea();
return s*h;
}
void showVolume(){
super.show();
System.out.println("圆的体积Perimeter=" + this.getVolume()) ;
}
}
class test{
public static void main(String[] args) {
// TODO code application logic here
Cylinder c=new Cylinder(10, 20);
c.showVolume();
} 展开
private float r=50;
double π=3.14;
double s;
double z;
Circle() {
}
public Circle(float r,double s,double z){
this.r=r;
this.s=s;
this.z=z;
}
public Circle(double s2) {
// TODO Auto-generated constructor stub
}
double getArea(){
return r*r*π;
}
double getPerimeter(){
return 2*π*r;
}
void show() { System.out.println("圆的半径Radius=" + r + ",圆的周长Perimeter=" + this.getPerimeter() + ",圆的面积Area=" + this.getArea());
}
}
class Cylinder extends Circle{
private double h=20;
Cylinder(double r, double h){
super(r);
}
double getVolume(){ super. getArea();
return s*h;
}
void showVolume(){
super.show();
System.out.println("圆的体积Perimeter=" + this.getVolume()) ;
}
}
class test{
public static void main(String[] args) {
// TODO code application logic here
Cylinder c=new Cylinder(10, 20);
c.showVolume();
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询