Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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. (1 pt) displays a list of the 3D shapes and their numbers,

  2. (1 pt) prompts the user to select a number 1 to 4, from the previously displayed list,

  3. (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.).

  4. (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).

  5. (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:

  1. A cylinder of 3.5 inches radius and 5.2 inches height.

  2. A cube of 6.33 inches radius.

  3. A sphere of 4.7 inches radius.

  4. A number of shape not in the list. For example, enter 6 for the shape number.

  5. A sphere of -5 inches radius.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions