Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

OUTLINE FOR LAB 3 Outer While 2 statements Prompt user to enter object name Start switch case (see Matlab code basic, survey embedded.m) and FOR_v_WHILE.m

image text in transcribedOUTLINE FOR LAB 3 Outer While 2 statements Prompt user to enter object name Start switch case (see Matlab code basic, survey embedded.m) and FOR_v_WHILE.m Example of one case: switch variable ( this is the variable that holds the name of the object) SIX cases one for each object case e.g. square input statements that ask the user for the necessary data. For square only the side is required. More dimensions are required For other objects Call Function (name of function will be defined by the Square area function after the outer while loop. One of six such functions.) Print answer returned by the called function. case (five more case structure as the first one. Variable after case is the object name, inputs follow to ask user for the appropriate data to calculate area or volume of this cases object. Call the appropriate function Print the answer the function computes) end for switch Repeat until six object cases and one otherwise case is completed. (Note the otherwise case only tells the user they enter the wrong data for the object name. Again object name is a string and data is numeric.) Prompt to determine if continue outer while or stop end (for outer while) Now SIX FUNCTIONS 3 to find areas 3 to find volumes Each totally independent.

LAB 3 FUNCTIONS Objective to learn how to write Functions. This lab will have a script and then 6 functions. For the Script, write an outer while loop for this lab so it can rerun the script controlled by user's input. The previous Labs required this also. The functions will be finding areas or volumes of geometric objects. Find the area of a Square, Circle, and Octagon. Find the volume of a Rectangular Prism, Cylinder, and Frustum of a cone. Requirements: 1. In the script ask the user to choose one of these 3 areas or 3 volumes. What statement do you need here to have the user input this data? This will be a single variable of type integer or string (string can be a single character.) Note if you input a string ' s ' must follow the prompt and be inside the right parenthesis. The dimensions will of course be numeric the objects names will be strings. 2. Use a switch case statement with the above 6 tasks as the specific cases and then an otherwise case. Seven cases in total since Otherwise is a case. 3. For each case do the following: a. Ask the user for the parameter(s) you need. e.g. for area of square you only need the side. Other areas and volumes you will need the variables to solve for area or volume (See equations above.). b. Call a function to solve for the area or volume of the object selected by the user. Note the call to a function will be in the form: Variable = "name-of-function" (parameter list); Parameter list is the items values in 3 above. The values need to calculate area or volume respectively. c. Use fprintf to output the answer e.g. Area or Volume of the specific object. 4. Write 6 functions: a. Each function will take the parameters and calculate the respective area or volume of the specific object

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

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions