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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started