Page 1 of 1

Question 4 (25 pts) Write a script 'shapes that when run prints a list consisting of "cylinder", "cube", "sphere". It pr

Posted: Sun May 15, 2022 8:44 am
by answerhappygod
Question 4 25 Pts Write A Script Shapes That When Run Prints A List Consisting Of Cylinder Cube Sphere It Pr 1
Question 4 25 Pts Write A Script Shapes That When Run Prints A List Consisting Of Cylinder Cube Sphere It Pr 1 (67.83 KiB) Viewed 44 times
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