eolymp
bolt
Try our new interface for solving problems
Problems

Java Abstract Shape

Java Abstract Shape

Time limit 1 second
Memory limit 128 MiB

Implement abstract class Shape.

Implement classes Rectangle, Triangle that extend Shape.

Implement class Square that extends Rectangle.

abstract class Shape
{
  int a, b;
  Shape(int a, int b) // Constructor
  abstract int Perimeter(); // Perimeter
  abstract double Area(); // Area
}

class Rectangle extends Shape
{
  Rectangle(int a, int b) // Constructor
  public int Perimeter() // Perimeter of Rectangle
  public double Area() // Area of Rectangle
}

class Square extends Rectangle
{
  Square(int a) // Constructor
}

class Triangle extends Shape
{
  int c;
  Triangle (int a, int b, int c) // Constructor
  public int Perimeter() // Perimeter of Triangle
  public double Area() // Area of Triangle
}

Input data

Each line contains one of three types of figures in the next format:

  • Square a

  • Rectangle a b

  • Triangle a b c

Output data

For each figure print in a separate line its perimeter and area.

Examples

Input example #1
Square 5
Rectangle 2 3
Triangle 3 4 5
Output example #1
20 25.0
10 6.0
12 6.0
Author Mykhailo Medvediev