Question
matlab only
Question 4 A restaurant sells five different desserts whose prices are shown below in the following table: Dessert number Uni
0 0
Add a comment Improve this question Transcribed image text
Answer #1

clear
clc

%displaying menu
fprintf('MENU: ')
fprintf('\nDessert number\tUnit Price')
fprintf('\n1\t\t\t\t$ 3.98')
fprintf('\n2\t\t\t\t$ 2.55')
fprintf('\n3\t\t\t\t$ 6.90')
fprintf('\n4\t\t\t\t$ 9.85')
fprintf('\n5\t\t\t\t$ 12.50')

more = true; % to allow a series of pairs to be entered
overallTotalPrice = 0;

while more
dessertNumber = input('\n\nDessert Number: ');   
  
switch dessertNumber
case 1
unitPrice = 3.98;
case 2
unitPrice = 2.55;
case 3
unitPrice = 6.90;
case 4
unitPrice = 9.85;
case 5
unitPrice = 12.50;
otherwise
error('unknown menu option')
end

quantitySold = input('Quantity Sold: ');

%capture quantity<0
if quantitySold<1
error('quantity must be atleast 1')
end


totalPrice = quantitySold*unitPrice; %for the current Dessert #

%computing overall total price cumulatively
overallTotalPrice = overallTotalPrice+totalPrice;

more = input('enter 0 to quit, or 1 to get more: ');%exiting program
end

%diaplying final total price when the customer quits
fprintf(['Total Price: $ ' num2str(overallTotalPrice) '\n\n'])


MENU: Dessert number Unit Price $ 3.98 $ 2.55 S 6.90 $ 9.85 s 12.50 Dessert Number 3 Quantity Sold: 12 enter 0 to quit, or 1

-----------------------------------------------------------------------------------

MENU: Dessert number Unit Price 1 S 3.98 $ 2.55 S 6.90 $9.85 S 12.50 Dessert Number 5 Quantity Sold: 3 enter 0 to quit, or l

COMMENT DOWN FOR ANY QUERY RELATED TO THIS ANSWER,

IF YOU'RE SATISFIED, GIVE A THUMBS UP
~yc~

Add a comment
Know the answer?
Add Answer to:
matlab only Question 4 A restaurant sells five different desserts whose prices are shown below in...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A mail order house sells five different products whose retail prices are: product 1: $2.98 product...

    A mail order house sells five different products whose retail prices are: product 1: $2.98 product 2: $4.50 product 3: $9.98 product 4: $4.49 product 5: $6.87. Write a program that reads a series of pairs of numbers as follows: a) product number b) quantity sold Your program should use a switch statement to determine the retail price for each product. Your program should calculate and display the total retail value of all products sold. Use a sentinel-controlled loop to...

  • An online retailer sells five products whose retail prices are as follows: Product 1, $2.98; product...

    An online retailer sells five products whose retail prices are as follows: Product 1, $2.98; product 2, $4.50; product 3, $9.98; product 4, $4.49 and product 5, $6.87. Write an application in C++ that reads a series of pairs of numbers as follows: a) product number b) quantity sold Your program should use a switch statement to determine the retail price for each product. It should calculate and display the total retail value of all products sold. Use the sentinel-controlled...

  • This is in C. 4.19 (Calculating Sales) An online retailer sells five different products whose retail...

    This is in C. 4.19 (Calculating Sales) An online retailer sells five different products whose retail prices are shown in the following table: Product number Retail price $ 2.98 $ 4.50 $9.98 $ 4.49 $6.87 Write a program that reads a series of pairs of numbers as follows: a) Product number b) Quantity sold for one day Your program should use a switch statement to help determine the retail price for each product. Your program should calculate and display the...

  • Babette's Bistro is a restaurant which sells delicious French bistro fare, although with a very limited...

    Babette's Bistro is a restaurant which sells delicious French bistro fare, although with a very limited selection. The menu consists of the following items with associated prices: Braised Rabbit $8.89 Crispy Duck $7.99 Grilled Steak $10.57 Write a Java program which displays a menu to the customer which allows them to place an order consisting of one or more items. The menu should use a simple numeric selection method to order an item. For example, '1' orders braised rabbit, '2'...

  • Utilizing Menu Engineering Concept in a Restaurant Operation The purpose of this assignment is fo...

    Utilizing Menu Engineering Concept in a Restaurant Operation The purpose of this assignment is four fold: Step 1. To learn basic menu engineering principles Step 2. To learn menu engineering strategies Step 3. To use a spreadsheet program in generating two menu engineering reports Step 4. To evaluate the information found in the menu engineering reports using the menu engineering strategy model presented in this assignment. This will be accomplished by answering 9 questions found at the end of this...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT