import java.io.*; import java.text.DecimalFormat; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] arr = br.readLine().split(" "); double l = Integer.parseInt(arr[0]); double w = Integer.parseInt(arr[1]); double ra = Integer.parseInt(br.readLine()); double ri = Integer.parseInt(br.readLine()); // 创建对象,求出面积。 double ar1, ar2, ar3; Shape sh1 = new Rectangle(l, w); Shape sh2 = new Circle(ra); Shape sh3 = new Square(ri); ar1 = sh1.getArea(); ar2 = sh2.getArea(); ar3 = sh3.getArea(); // 处理第二个图形面积的返回值,否则通不过测试 int area2 = (int)ar2; String s; double temp; DecimalFormat df = new DecimalFormat("###.0"); if (ar2 > area2) { temp = Double.parseDouble(df.format(ar2)); if (temp != ar2) { s = String.format("%.2f", ar2); } else { s = Double.toString(ar2); } } else { s = Integer.toString(area2); } System.out.printf("%.0f\n%s\n%.0f", ar1, s, ar3); } abstract static class Shape { // 私有数据x,y private double x; private double y; // 抽象方法:使派生类Rectangle和类Circle都必须重写方法getArea() abstract double getArea(); } private static class Rectangle extends Shape { // Rectangle类自有属性:长和宽 private double length; private double weight; // 有参构造,正方形Square类继承时用来赋值属性 private Rectangle(double ride) { this.length = ride; this.weight = ride; } // 有参构造 private Rectangle(double length, double weight) { this.length = length; this.weight = weight; } // getArea方法重写 @Override public double getArea() { return length * weight; } } private static class Circle extends Shape { // Circle类自有属性:长和宽 private double radius; // 有参构造 private Circle(double radius) { this.radius = radius; } // getArea方法重写 @Override public double getArea() { return 3.14 * radius * radius; } } private static class Square extends Rectangle { // 有参构造 private Square(double ride) { // 参数送到父类,用父类一个参数的构造器创建对象 super(ride); } } }