11422 - Shape   

Description

Warning: You are not allowed to use malloc and free

Following the lecture slide :

Giving a bass-class Shape and 3 derived class : Triangle, Rectangle, Circle

You need to calculate the area and the perimeter of each shape.

note : You need to do some basic check: if the given information cannot form a shape (e.g. height of the rectangle is negative number....etc), then the area and perimeter would be both 0)

Input

There are only 3 shapes in this problem :

  • Triangle, following by its 3 edges. (e.g. Triangle 3 4 5)
  • Rectangle, following by its width and height. (e.g. Rectangle 5 7)
  • Circle, following by its radius and the value of pi. (e.g. Circle 2 3.14)

Output

Ouput the total area and perimeter of all the shapes.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11422.cpp

Partial Judge Header

11422.h

Tags




Discuss