Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

Computer Science

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

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question