Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can you solve this problem in MATLAB? Sphere Cuboid Cylinder A=2(lw + wh + hl) 4 The formulas for determining the area and volume of
Can you solve this problem in MATLAB?
Sphere Cuboid Cylinder A=2(lw + wh + hl) 4 The formulas for determining the area and volume of three 3D shapes, 1. Cuboid, 2. Cylinder and 3. Sphere, are shown in the table and figure above. Write a script HW5P3 that, i. (1 pt) displays a list of the 3D shapes and their numbers, ii. (1 pt) prompts the user to select a number 1 to 4, from the previously displayed list, ii. (5 pts) based on the user's selection, the program then asks the user to enter the required dimensions for determining the area and volume of the shape selected. For example, (the radius only for the sphere, the base radius and height for a cone, etc.). (6 pts) The program then determines the area and volume of that specific shape from the formulas given above and prints these values in the following format: iv. a cylinder as an example, the program prints, "For a cylinder of XX in radius and XX in height, the surface area XX in*2 and the volumeXX in 3 Xx is the number of each dimension with 2 decimals. Similar text must be printed for every shape based on the name of the shape and its dimensions. (All dimensions are assumed to be in inches) (3 pts) If the user enters an invalid choice, the script simply prints an error message. For example, if the user entered a number of shape that is not in the list or entered an invalid negative dimension, the script must print "Invalid Entry, please check your inputs and try again." v. Your script may combine between switch-case and if-else structures (4 pts) Use your script with the following cases: a. A cylinder of 3.5 inches radius and 5.2 inches height. b. A cube of 6.33 inches radias: Side le 8th c. A sphere of 4.7 inches radius. d. A number of shape not in the list. For example, enter 6 for the shape number. e. A sphere of -5 inches radius. Below is an example of the display in the command window upon runn the cylinder case, HW5P3 3D Shape List: 1.Cuboid 2.Cylinder 3.Sphere Please choose a number from the list above: 2 Please enter the radius of the cylinder in inches: 4 Please enter the height of the cylinder in inches: For a Cylinder of 4.00 in radius and 6.00 in height, in^3. 301.59 the surface area = 251.33 in^2 and the volumeStep 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