Java Regular Polygon#10496

Java Regular Polygon

1 second
128 megabytes
Very easy
interface RegularPolygon {
  int getNumSides();
  double getSideLength();

  static int totalSides(RegularPolygon[] rpArray) {
  }

  default double getPerimeter() {
  }
  default double getInteriorAngle() {
  }
}

class EquilateralTriangle implements RegularPolygon {
  private double sideLength;

  public EquilateralTriangle(double sideLength) {
  }

  public int getNumSides() {
  }

  public double getSideLength() {
  }

  public String toString() {
  }
}

class Square implements RegularPolygon {
  private double sideLength;

  public Square(double sideLength) {
  }

  public int getNumSides() {
  }

  public double getSideLength() {
  }

  public String toString() {
  }
}

public class Main {
  public static void main(String[] args) {
    Scanner con = new Scanner(System.in);
    int n = con.nextInt();
    RegularPolygon[] rpArray = new RegularPolygon[n];
    ...
    con.close();
  }
}

Write a program that meets the following requirements:

Add two default methods:

Input

The first line contains an integer (n \leq 100), the number of geometric figures. Each of the next lines contains the name of the figure (Triangle or Square) and its side length (a real number).

Output

For each figure, print its name, side length, perimeter, and the value of its interior angle, formatted as in the sample output. In the last line, print the total number of sides among all figures.

prb10496.gif

Examples

Example 1

Loading
Loading