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'])
-----------------------------------------------------------------------------------
COMMENT DOWN FOR ANY QUERY RELATED TO THIS ANSWER,
IF YOU'RE SATISFIED, GIVE A THUMBS UP
~yc~
matlab only Question 4 A restaurant sells five different desserts whose prices are shown below in...
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...
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...