Question 4 (25 pts) Write a script 'shapes that when run prints a list consisting of "cylinder", "cube", "sphere". It pr
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Question 4 (25 pts) Write a script 'shapes that when run prints a list consisting of "cylinder", "cube", "sphere". It pr
Question 4 (25 pts) Write a script 'shapes that when run prints a list consisting of "cylinder", "cube", "sphere". It prompts the user to choose one, and then prompts the user for the relevant quantities e.g. the radius and length of the cylinder and then prints its surface area. If the user enters an invalid choice like 'O' or '4' for example, the script simply prints an error message. Similarly for a cube it should ask for side length of the cube, and for the sphere, radius of the sphere. You can use three functions to calculate the surface areas or you can do without functions as well. The script should use nested if-else statement to accomplish this. Here are the sample outputs you should generate (ignore the units): >> shapes Menu 1. Cylinder 2. Cube Sphere Please choose one: 1 Enter the radius of the cylinder: 5 Enter the length of the cylinder: 10 The surface area is: 314.1593 3. >> shapes Menu 1. Cylinder 2. Cube 3. Sphere Please choose one: 2 Enter the side-length of the cube: 5 The volume is: 150.0000 2. >> shapes Menu 1. Cylinder Cube 3. Sphere Please choose one: 3 Enter the radius of the sphere: 5 The volume is: 314.1593
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!