[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(double a)
{
r = a;
}
public Circle()
{
r = 0;
}
public void setR(double a)
{
r = a;
}
public double getPerimeter()
{
return 2*3.14*r;
}
public double getArea()
{
return 3.14*r*r;
}
}