Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer 1c, use MATLAB, and paste your entire script in your answer so that I can copy and paste to see if it works.

Please answer 1c, use MATLAB, and paste your entire script in your answer so that I can copy and paste to see if it works.

image text in transcribed

image text in transcribed

Problem #1 400g triangle square pentagon hexagon Figure 1 For a closed geometric figure composed of straight lines (Figure 1), the interior angles in the figure must add to (n-2)(180) where n is the number of sides. Required Tasks a) Write a script that prompts the user to select from one of the following shapes: triangle, square, pentagon, hexagon Prompt the user to enter the first letter of the shape (t' or 'T' for triangle, etc.) as input. Use an appropriate if-else or if-elseif statement to select the corresponding value of n for the chosen shape. Next, calculate and display the sum of the internal angles of the shape. If the user enters an invalid choice, display an error message and prompt for another shape. This should continue until the user enters a valid choice. Save your script file using this file name: hw4x1a.m b) Make a new version of your script that replaces the if statement with a switch-case statement instead. Save your script file using this file name: hw4x1b.m c) Create a final version that replaces the if statement with a menu function call that shows the choices in a pop-up graphical window and allows the user to click the desired shape to calculate. Save your script file using this file name: hw4x1c.m Sample runs in the command window >> hw4xla Shape choices [t]riangle [s] quare [P]entagon [h]exagon Enter first letter of shape: x Error: Invalid shape. Please try again. Enter first letter of shape: m Error: Invalid shape. Please try again. Enter first letter of shape: t Sum of angles = 180 degrees >> hw4xla Shape choices [t]riangle [s] quare [P]entagon [h]exagon Enter first letter of shape: P Sum of angles = 540 degrees

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

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions