Answered step by step
Verified Expert Solution
Question
1 Approved Answer
( Solve using matlab ) Objective to use Select Case and get experience writing functions.Write the program to cycle until the users chooses to stop.
Solve using matlab
Objective to use Select Case and get experience writing functions.Write the program to cycle until the users chooses to stop. Look at Lecture code for While Loop structure, dont forget the input at end of while.We will use geometric objects in this lab.Object one: Circle defined by radius. Write functions one to compute the area of a Circie and the other to compute the volume of a cylinder.Object two: Triangle See explanation below that defines a triangle by sides where any sides must be greater than the third. So if you pick sides then the third side must be greater than the sum of the first Example: side side side Note the Area of a triangle can be computed with only the sides by herons formula: Write functions, one to compute the area of a triangle using herons formula and one to compute the volume of a D object with crosssection of a triangle and height.Object three: Parallelogram defined by two adjacent sides and the included angle. Write functions, one to compute the area of the parallelogram and one to compute the volume of a D object with crossSection of the parallelogram and height.Requirements:Write a script and functions, one for each of the objects above. The script will use a switch case statement to select one of the objects, D objects and D objects. Then in each case you will call a function to solve for the mathematical answers Prior to SwitchCase you must ask the user to choose which object they wish to solve. The target variable of the Switch may be a numeric variable or a string Switch case with active cases and otherwise. In each case the appropriate user inputs must be requested via input statements. See Object descriptions above for the appropriate respective inputs for each unique object. The D objects have one more parameters which is height These inputs will become the input parameters to the function you call The function will return outputs that are the answers back to the case for display to the user. Requirements: In the script ask the user to choose one of these areas or 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 Use a switch case statement with the above tasks as the specific cases and then an otherwise case. Seven cases in total since Otherwise is a case.Write functions that are called in the six cases:For each case do the following:a Ask the user for the parameters you need. eg for area of square you only need the side. Other areas and volumes you will need the variables to solve for area or volumeb. Call a function to solve for the area or a different function for the volume of the object selected by the user. Note the call to a function will be in the form:Variable nameoffunction parameter list ; Parameter list is the items values in above. The parameter values need to be the items necessary to calculate area or volume respectively.c Use fprintf to output the answer eg Area or Volume of the specific object Each function will have output variable, and inputs based on the data needed to compute the area of the crosssectional shape ie circle, triangle, or parallelogram. In the volume functions you need to add the height plus parameters for the area.
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