Question: Write a Matlab Script (Program) including: - User interaction: input and output - If/Else to make decisions - Loops to get multiple inputs, validate inputs,
Write a Matlab Script (Program) including:
- User interaction: input and output
- If/Else to make decisions
- Loops to get multiple inputs, validate inputs, and find a sum and maximum of inputs
General Description: Write a script that allows a specialty sheet metal company to calculate a customers order. The company cuts and sells sheet metal of various shapes and sizes. The price of each item is determined by the surface area of each sheet cut. When the price of all items exceeds $100, and 2 or more items are purchased, the cheapest item is discounted by 50%. The script first asks the user how many items are to be ordered. For each item, the user is asked for the shape of the item, which should be validated. Depending on the shape chosen, the user is then asked for the pertinent dimensions, and the area of the item is calculated. The price of the item is then calculated as $1.15 per square foot. The total price of each item is summed, and the program should track the price of the cheapest item. After all items are entered, summed and checked for being the cheapest, the program applies the discount (if any) described above and calculates the total price of the items. Tax is calculated as 6% of the subtotal, and the total as subtotal plus tax. This information is printed on the screen for the user. Print the subtotal, discount (only if it is not zero), tax and total.
Specifications: the algorithm is - Use the semicolon to eliminate Matlab Clutter from any statement.
- Clear the screen and clear all variables.
- Ask the user how many items are to be purchased.
- For each item: o Print Select a shape for item #: where # is the item number. Ask the user for the shape:
1. Rectangle, 2. Triangle or 3. Circle. Whenever the user enters an invalid answer, print Invalid option, try again! and repeat the question until a valid answer is entered.
Calculate the area:
When the selected shape is Rectangle: Ask the user to enter the length and width.
When the shape is Triangle: Ask the user to enter the base and height.
When the shape is Circle: Ask the user to enter the radius of the circle [use the pi() function for the calculation]
Note: all measurements are assumed to be in feet.
o Calculate the price as $1.15 per square foot.
o Print the price of the item with the item number.
o Add the price to the running subtotal, and check if the price of the item is the cheapest entered so far.
- When the number of items is 2 or more, and the subtotal is $100 or more, subtract half the price of the cheapest item.
- Calculate tax (6%) and Total - Print a receipt as shown in the examples below, including lining up the dollar signs. Round all dollar amounts to 2 places past the decimal point using the round() function.
Sample Execution 1: demonstrates validation loop. Note no discount is applied or printed Enter number of items purchased: 1 Select a shape for item 1: 1. Rectangle 2. Triangle 3. Circle Enter number 1-3: 0 Invalid option, try again! Enter number 1-3: 4 Invalid option, try again! Enter number 1-3: -2 Invalid option, try again! Enter number 1-3: 2 Enter base length of triangle: 8 Enter height of triangle: Item 1 price: $23 Sheet Metal Order Sub Total: $ 18.4 Tax: Total: $ 1.1 $ 19.5 Sample Execution 2: demonstrates 3 items with discount Enter number of items purchased: 3 Select a shape for item 1: 1. Rectangle 2. Triangle 3. Circle Enter number 1-3: 1 Enter length of rectangle: 10 Enter width of rectangle: 10 Item 1 price: $115 Select a shape for item 2: 1. Rectangle 2. Triangle 3. Circle Enter number 1-3: 2 Enter base length of triangle: 10 Enter height of triangle: Item 1 price: $57.5 Select a shape for item 3: 1. Rectangle 2. Triangle . Circle Enter number 1-3: 3 Enter radius of circle: 10 Item 1 price: $361.28 Sheet Metal Order Sub Total: $ 476.28 Discount: 57.5 Tax: $ 28.58 Total: 504.86 10
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
