A online retailer has hired you to write a program to calculate the total cost of a customer’s order. First, the retailer must enter the name and the price per unit for two different candies. Then, the customer is allowed to order as many units of each of the two candies as they would like. Lastly, an invoice (report) is generated (displayed to the screen) under the following rules:
1. All units up to and including the 20th are sold at full price.
2. All unit in excess of 20 are sold at a 10% discount.
3. For each candy there must be a separate line indicating:
◦ The candy’s name
◦ The candy’s full unit price
◦ How many units are being sold at full unit price
◦ The resulting subtotal
And if applicable, another line indicating:
◦ The candy’s name
◦ The candy’s discounted unit price
◦ How many units are being sold at discounted unit price
◦ The resulting subtotal
4. There must be a line indicating the total of the order.
5. There must be a line indicating the sales tax on the total of the order (based on a 5% sales tax)
6. There must be a line indicating the grand total of the order.
Finish the following MATLAB function and write a MATLAB Script that (uses that function) to satisfy the above description.
function [ fpUnits, fpSubtotal, disUnits, disSubtotal ] = proccessCandy( unitsSold, unitPrice, discountThr, discount )
%proccessCandy Compute values for each candy
%{
INPUT:
—–
unitsSold – Total number of candy units being sold
unitPrice – Full price of each unit
discountThr – The number of units that must be exceeded
before applying discount
discount – The discount rate to be applied eg (15% -> 0.15)
OUTPUT:
——
fpUnits – How many units being sold at full price
disUnits – How many units being sold at discounted price
fpSubtotal – Total cost of full priced units
disSubtotal – Total cost of discounted priced units
%}
% your formulas and logic here
end
Select your paper details and see how much our professional writing services will cost.
Our custom human-written papers from top essay writers are always free from plagiarism.
Your data and payment info stay secured every time you get our help from an essay writer.
Your money is safe with us. If your plans change, you can get it sent back to your card.
We offer more than just hand-crafted papers customized for you. Here are more of our greatest perks.
Get instant answers to the questions that students ask most often.
See full FAQ