急急急!!!小弟的JAVA考试题目!!!!
以下程序能否通过编译?如不能通过编译,请之处产生错误的原因以及改正的办法!!!!!!publicclassCircle{privatedoublexPos=0;priva...
以下程序能否通过编译?如不能通过编译,请之处产生错误的原因以及改正的办法!!!!!!
public class Circle {
private double xPos = 0;
private double yPos = 0;
private double radius = 1;
public Circle (double x,double y,double r) {xPos=x; yPos=y; radius=r;}
public double perimeter() {return 2 * 3.14*radius;}
public double area() {return 3.14 * radius * radius; }
public static void main(String[] args) {
Circle figure = new Circle();
System.out.println(figure.perimeter());
System.out.println(figure.area());
}
}
能否写得详细一点?谢谢高手!!! 展开
public class Circle {
private double xPos = 0;
private double yPos = 0;
private double radius = 1;
public Circle (double x,double y,double r) {xPos=x; yPos=y; radius=r;}
public double perimeter() {return 2 * 3.14*radius;}
public double area() {return 3.14 * radius * radius; }
public static void main(String[] args) {
Circle figure = new Circle();
System.out.println(figure.perimeter());
System.out.println(figure.area());
}
}
能否写得详细一点?谢谢高手!!! 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询