Question: Write a Java Code.Write a code that calculates the volume of a 3d geometrical shape using a switch with 5 cases. The system should take

Write a Java Code.Write a code that calculates the volume of a 3d geometrical shape using a switch with 5 cases. The system should take a String input for each of the following cases; Cube, Rectangularprism, Cylinder, Cone, and Sphere. And 1 to 3 double inputs depending on each shape. The volume should be printed as a double with 2 digits after the decimal.

Cube: gets length as an input Rectangularprism: gets length, width, and height as an input Cylinder: gets radius, and height as an input Cone: gets radius and height as an input Sphere: gets radius as an input

Note: Take pi as 3.14

Input Format

For String = Cube, Rectangularprism, Cylinder, Cone, or Sphere. Double; radius, length, width, and/or height respectively.

Constraints

2 any double 100

Output Format

Print a single Volume, in the following format: XXX,00

Sample Input 0

Sphere 6 

Sample Output 0

902.06

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!