Java Abstract Shape
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
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
Each line contains one of three types of figures in the next format:
Square a
Rectangle a b
Triangle a b c
Output
For each figure print in a separate line its perimeter and area.
Examples
Input #1
Answer #1
Submissions 2K
Acceptance rate 31%