eolymp
bolt
Try our new interface for solving problems
Problems

Java Inheritance Rectangle Square

Java Inheritance Rectangle Square

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 a and b are sides of rectangle. In the case of a square a is its side.

Output

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

Time limit 1 second
Memory limit 128 MiB
Input example #1
Rectangle 4 5
Square 7
Square 2
Output example #1
20 18
49 28
4 8
Author Michael Medvedev