11467 - 3DShape   

Description

Warning: You are not allowed to use malloc and free

Giving a bass-class Shape3D and 2 derived class : Sphere, Cube 

You need to calculate the volume of each shape.

PS:

V of Sphere: V = 4/3 π r3

note : Remember to do some basic check, if the input is illegal (e.g.  length < 0, pi < 0 .....)  then the volume should be 0.

You don't need to consider the scenario like Cube -2, volume would be 0 instead of -8.

Hint1: Be careful the type of volume is double.  4/3=1 (int),  so it should be 4.0/3.0

Hint2: You only need to implement the constructors.

Input

There are only 2 shapes in this problem :

  • Sphere, following by its radius and pi. (e.g. Sphere 30 3.14)
  • Cube, following by its length. (e.g. Cube 2)

Output

Ouput the total volume of all the shapes.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11467.cpp

Partial Judge Header

11467.h

Tags




Discuss