[java]代码库
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
double r_c1 = scan.nextDouble();
double r_c2 = scan.nextDouble();
scan.close();
Circle c1 = new Circle();
c1.setR(r_c1);
System.out.println(c1.getArea());
System.out.println(c1.getPerimeter());
Circle c2 = new Circle(r_c2);
System.out.println(c2.getArea());
System.out.println(c2.getPerimeter());
}
}
class Circle {
private double r;
public Circle() {
r = 0;
}
public Circle(double _r) {
r = _r;
}
public void setR(double _r) {
r = _r;
}
public double getPerimeter() {
double p = 2*3.14*r;
return p;
}
public double getArea() {
double a = 3.14*r*r;
return a;
}
}