At Westonci.ca, we connect you with the best answers from a community of experienced and knowledgeable individuals. Get precise and detailed answers to your questions from a knowledgeable community of experts on our Q&A platform. Connect with a community of professionals ready to help you find accurate solutions to your questions quickly and efficiently.

Python: Write a program for a small restaurant that sells pizzas. You may consider it as a prototype of a realistic online application. Basically, your program allows a user to enter one’s name and information about pizzas that the user wants to order. It then calculates and displays the subtotal, sales tax, and total cost of the order.

Given below is a typical dialog between a user and your program when the user interacts with your program to place an order of one or more pizzas. Note that the text in black is program output, such as asking the user for certain input or displaying relevant information for the user, and the text in red is the user’s response to a prompt from your program.

Enter your name: John

Enter the number of pizzas you want to order: 2

Pizza Size and Cost

- Small (10 inch, $7.95), Medium (12 inch, $9.95), and Large (14 inch, $11.95) Enter the size of your pizzas: Medium

Available Topping and Cost Per Topping

- Ham, Mushrooms, Onions, Green Peppers, Black Olives, Tomatoes, Pineapple, Spinach

- $0.75 each for Small Pizza, $0.95 each for Medium Pizza, and $1.15 each for Large Pizza Enter the number of toppings on your pizzas: 3

Enter your choices of toppings: Onions, Pineapple, Spinach

Order Summary

Customer name: John

2 Medium Pizzas with Toppings Onions Pineapple Spinach

Subtotal:

Sales Tax (6.0%): Total Cost:

$22.15 $1.33 $23.48

Develop your program according to the dialog above.


Sagot :

Answer:

Name: tyler

Number of pizzas: 2

Small (10 inch, $7.95), Medium (12 inch, $9.95), and Large (14 inch, $11.95)

Pizza size: large

Available toppings: Ham, Mushrooms, Onions, Green Peppers, Black Olives, Tomatoes, Pineapple, Spinach

$0.75 each for Small Pizza, $0.95 each for Medium Pizza, and $1.15 each for Large Pizza

Number of toppings: 2

Enter topping number 1: ham

Enter topping number 2: onions

Order Summary:  

Customer Name: tyler

2 large pizzas with ['ham', 'onions']        

Subtotal | Sales Tax (6%) | Total Cost        

26.2 | 1.5719999999999998 | 27.772

Explanation:

name = input("Name: ")

num_pizzas = int(input("Number of pizzas: "))

print("Small (10 inch, $7.95), Medium (12 inch, $9.95), and Large (14 inch, $11.95)")

pizza_size = input("Pizza size: ").lower()

print("Available toppings: Ham, Mushrooms, Onions, Green Peppers, Black Olives, Tomatoes, Pineapple, Spinach")

print("$0.75 each for Small Pizza, $0.95 each for Medium Pizza, and $1.15 each for Large Pizza")

num_toppings = int(input("Number of toppings: "))

toppings = []

subtotal = 0

tax = 0

total = 0

for i in range(1,num_toppings + 1):

   toppings.append(input(f"Enter topping number {i}: "))

if pizza_size == 'small':

   subtotal += num_pizzas * 7.95

   subtotal += num_toppings * 0.75

   tax += subtotal * 0.06

   total += subtotal + tax

   print("Order Summary: ")

   print(f"Customer Name: {name}")

   print(f"{num_pizzas} {pizza_size} pizzas with {toppings}")

   print("Subtotal | Sales Tax (6%) | Total Cost")

   print(f"{subtotal} | {tax} | {total}")

if pizza_size == 'medium':

   subtotal += num_pizzas * 9.95

   subtotal += num_toppings * 0.95

   tax += subtotal * 0.06

   total += subtotal + tax

   print("Order Summary: ")

   print(f"Customer Name: {name}")

   print(f"{num_pizzas} {pizza_size} pizzas with {toppings}")

   print("Subtotal | Sales Tax (6%) | Total Cost")

   print(f"{subtotal} | {tax} | {total}")

if pizza_size == 'large':

   subtotal += num_pizzas * 11.95

   subtotal += num_toppings * 1.15

   tax += subtotal * 0.06

   total += subtotal + tax

   print("Order Summary: ")

   print(f"Customer Name: {name}")

   print(f"{num_pizzas} {pizza_size} pizzas with {toppings}")

   print("Subtotal | Sales Tax (6%) | Total Cost")

   print(f"{subtotal} | {tax} | {total}")

Thanks for using our platform. We're always here to provide accurate and up-to-date answers to all your queries. Thanks for stopping by. We strive to provide the best answers for all your questions. See you again soon. Keep exploring Westonci.ca for more insightful answers to your questions. We're here to help.