Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3. A pizza store is giving a discount when you buy 3 or more pizzas. The followi

ID: 3811799 • Letter: 3

Question

3. A pizza store is giving a discount when you buy 3 or more pizzas. The following table shows the price per pizza if you add-on peppers, mushrooms, or peppers and mushrooms to the pizzas. The cost per pizza decreases if you order more pizzas. Number of Pizzas 3 5 Pizza Add-ons Peppers $5.99 $5.49 $4.99 $6.49 $5.99 $5.49 Mushrooms Peppers and Mushrooms LS699 LS649 LS599 Write a script that does the following: Uses the menu function to ask the user to select between peppers, mushrooms or peppers and mushrooms Uses the menu function to ask the user if they want 3, 4, or 5 pizzas Calculates the total cost for the options selected. use switch-case to do this. Display a formatted print statement that displays the cost; it should look like the example below. Your total cost for 5 pizzas is $29.95.

Explanation / Answer

type=menu('Choose one of these','Peppers','Mushrooms','Peppers and Mushrooms'); %displays menu to choose type
number=menu('Choose number of pizzas',3,4,5); %displays menu to choose number
cost=0;
number1=0;

%using switch case calculate cost
switch(type)
case 1
switch(number)
case 1
number1=3;
cost=3*5.99;

case 2
number1=4;
cost=4*5.49;

case 3
number1=5;
cost=5*4.99;
end
case 2
switch(number)
case 1
number1=3;
cost=3*6.49;

case 2
number1=4;
cost=4*5.99;

case 3
number1=5;
cost=5*5.49;
end
case 3
switch(number)
case 1
number1=3;
cost=3*6.99;

case 2
number1=4;
cost=4*6.49;

case 3
number1=5;
cost=5*5.99;
end
end

fprintf('Your total cost for %d pizzas is %f',number1,cost); %display cost

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote