Question
PLEASE HELP! SOLVE USING MATLAB! The formulas for determining the area and volume of three 3D shapes, 1. Cuboid, 2. Cylinder and 3. Sphere, are
PLEASE HELP! SOLVE USING MATLAB!
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,
-
(1 pt) displays a list of the 3D shapes and their numbers,
-
(1 pt) prompts the user to select a number 1 to 4, from the previously displayed list,
-
(5 pts) based on the users 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:
for 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 volume = XX 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.
Your script may combine between switch-case and if-else structures. (4 pts) Use your script with the following cases:
-
A cylinder of 3.5 inches radius and 5.2 inches height.
-
A cube of 6.33 inches radius.
-
A sphere of 4.7 inches radius.
-
A number of shape not in the list. For example, enter 6 for the shape number.
-
A sphere of -5 inches radius.
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