Java Inheritance Rectangle Square#9657

Java Inheritance Rectangle Square

1 second
128 megabytes
Very easy

Implement a class Rectangle.

Implement a class Square that extends Rectangle.

class Rectangle
{
  private int a, b; // private variable
  Rectangle(int a, int b) // Constructor
  public int Area() // return area
  public int Perimeter() // return perimeter
}

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

Input

Each line contains one of two figures in the next format:

  • Rectangle a b

  • Square a

Here and are sides of rectangle. In the case of a square is its side.

Output

For each figure print in one line its area and perimeter.

Examples

Example 1

Loading
Loading