Question: Write a program to calculate the volume of a sphere, cylinder, or box (a parallelepiped with right angles). The user should enter an s or

Write a program to calculate the volume of a sphere, cylinder, or box (a parallelepiped with right angles). The user should enter an s or S for a sphere, a c or C for a cylinder, or a b or B for a box. Use a while loop to confirm that the user entered a correct letter. Depending on the users input for shape the user should be prompted for the appropriate dimensions using a switch structure. Validate input for dimensions using a whileloop for each entered dimension. Make sure that your while loop to check dimensions outputs what dimension is incorrect (see below for an example message). The while loops to check dimensions should be inside the branches of the switch. None of the while loops should contain selection structures. Then calculate the volume. The length of the box cannot be less than zero. Please enter the length of the box again. Your program should output the shape the user entered, the dimensions he/she entered as well as the calculated volume (Hint look at the demo program that uses a switch for an integer calculator for hints).

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!