Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A pizza ordering service allows customers to design their own pizza. There are three sizes: small, medium and large. A pizza can have a thick

A pizza ordering service allows customers to design their own pizza. There are three sizes: small, medium and large. A pizza can have a thick or thin base. All pizzas come with tomato and cheese toppings as standard and there are six additional types of topping available: Pepperoni Chicken Extra cheese Mushrooms Spinach Olives Pizzas always come with tomato and cheese toppings as standard, and can have up to three additional toppings. Customers need to be able to design their own pizza and then confirm or change it. Records are kept showing the number of pizzas sold for each base and size. The number of sales for each additional topping is also recorded. Write and test a program or programs for the pizza ordering service. Your program or programs must include appropriate prompts for the entry of data. Error messages and other output need to be set out clearly and understandably. All variables, constants and other identifiers must have meaningful names. You will need to complete these three tasks. Each task must be fully tested. TASK 1 Design your pizza. The customer is given choices of size, base and additional toppings (number and type) as stated above. Only valid choices can be accepted. The customer is asked to confirm their order or alter their choices or not proceed. If the customer confirms their order they are given a unique order number. TASK 2 Record the choices. Extend TASK 1 to record totals for the choices made for ordered pizzas only and calculate the total number of pizzas ordered. TASK 3 Find the most and least popular additional pizza toppings. Using your results from TASK 2, display the most popular and least popular additional toppings as a percentage of the total number of additional toppings ordered.

But I'm already done my coding, still show up error on task 3

import random from tabulate import tabulate

pizza_count = 0

pepperoni_count = 0 chicken_count = 0 extra_cheese_count = 0 mushrooms_count = 0 spinach_count = 0 olives_count = 0

pepperoni = 0 chicken = 0 extra_cheese = 0 mushrooms = 0 spinach = 0 olives = 0

topping_no = 0

print("##ORDERING SERVICE SELECTION MENU##") data = [["Pepperoni", "Small", "Thick"], ["Chicken", "Medium", "Thin"], ["Extra Cheese", "Large"], ["Mushrooms"], ["Spinach"], ["Olives"]] col_names = ["TOPPINGS", "SIZES", "BASES"] print(tabulate(data, headers=col_names, tablefmt="fancy_grid"))

def base(): base_choice = input(" Select Base: ") base_choice = base_choice.lower() if (base_choice != "thick") and (base_choice != "thin"): print("#Invalid Input#") base() def size(): size_choice = input(" Select Size: ") size_choice = size_choice.lower() if (size_choice != "small") and (size_choice != "medium") and (size_choice != "large"): print("#Invalid Input#") size()

def topping1(): topping_choice1 = input("Select Topping 1: ") topping_choice1 = topping_choice1.lower() if topping_choice1 == "pepperoni": global pepperoni_count global topping_no topping_no = topping_no + 1 pepperoni_count = pepperoni_count + 1 elif topping_choice1 == "chicken": global chicken_count topping_no = topping_no + 1 chicken_count = chicken_count + 1 elif topping_choice1 == "extra cheese": global extra_cheese_count topping_no = topping_no + 1 extra_cheese_count = extra_cheese_count + 1 elif topping_choice1 == "mushrooms": global mushrooms_count topping_no = topping_no + 1 mushrooms_count = mushrooms_count + 1 elif topping_choice1 == "spinach": global spinach_count topping_no = topping_no + 1 spinach_count = spinach_count + 1 elif topping_choice1 == "olives": global olives_count topping_no = topping_no + 1 olives_count = olives_count + 1 else: print("#Invalid Input#") topping1() def topping2(): topping_choice2 = input("Select Topping 2: ") topping_choice2 = topping_choice2.lower() if topping_choice2 == "pepperoni": global pepperoni_count global topping_no topping_no = topping_no + 1 pepperoni_count = pepperoni_count + 1 elif topping_choice2 == "chicken": global chicken_count topping_no = topping_no + 1 chicken_count = chicken_count + 1 elif topping_choice2 == "extra cheese": global extra_cheese_count topping_no = topping_no + 1 extra_cheese_count = extra_cheese_count + 1 elif topping_choice2 == "mushrooms": global mushrooms_count topping_no = topping_no + 1 mushrooms_count = mushrooms_count + 1 elif topping_choice2 == "spinach": global spinach_count topping_no = topping_no + 1 spinach_count = spinach_count + 1 elif topping_choice2 == "olives": global olives_count topping_no = topping_no + 1 olives_count = olives_count + 1 else: print("#Invalid Input#") topping2()

def topping3(): topping_choice3 = input("Select Topping 3: ") topping_choice3 = topping_choice3.lower() if topping_choice3 == "pepperoni": global pepperoni_count global topping_no topping_no = topping_no + 1 pepperoni_count = pepperoni_count + 1 elif topping_choice3 == "chicken": global chicken_count topping_no = topping_no + 1 chicken_count = chicken_count + 1 elif topping_choice3 == "extra cheese": global extra_cheese_count topping_no = topping_no + 1 extra_cheese_count = extra_cheese_count + 1 elif topping_choice3 == "mushrooms": global mushrooms_count topping_no = topping_no + 1 mushrooms_count = mushrooms_count + 1 elif topping_choice3 == "spinach": global spinach_count topping_no = topping_no + 1 spinach_count = spinach_count + 1 elif topping_choice3 == "olives": global olives_count topping_no = topping_no + 1 olives_count = olives_count + 1 else: print("#Invalid Input#") topping3()

def topping_number(): topping_no = int(input(" No. of Toppings: ")) if topping_no == 1: topping_no = 1 topping1() elif topping_no == 2: topping_no = 2 topping1() topping2() elif topping_no == 3: topping_no = 3 topping1() topping2() topping3() elif topping_no == 0: topping_no = 0 else: print("#Invalid Input#") topping_number() def randomnumber(N): minimum = pow(10, N-1) maximum = pow(10, N) - 1 return random.randint(minimum, maximum)

def status(): confirm = input(" Confirm [Yes/No]: ") confirm = confirm.lower() if confirm == "yes": print("Order Number:", randomnumber(10)) global pizza_count pizza_count = pizza_count + 1 elif confirm == "no": base() size() topping_number() status() else: print(" #Invalid input#") status()

def pizza(): base() size() topping_number() status() pizza_order() def pizza_order(): order = input(" Would you like to add another pizza [Yes/No]: ") order = order.lower() if order == "yes": pizza() elif order == "no": print("Number of Pizzas Ordered:", pizza_count) else: print("#Invalid Input#") pizza_order()

pizza()

pepperoni_calc = (pepperoni_count/topping_no)*100 pepperoni_calc = int(pepperoni_calc)

chicken_calc = (chicken_count/topping_no)*100 chicken_calc = int(chicken_calc)

extra_cheese_calc = (extra_cheese_count/topping_no)*100 extra_cheese_calc = int(extra_cheese_calc)

mushrooms_calc = (mushrooms_count/topping_no)*100 mushrooms_calc = int(mushrooms_calc)

spinach_calc = (spinach_count/topping_no)*100 spinach_calc = int(spinach_calc)

olives_calc = (olives_count/topping_no)*100 olives_calc = int(olives_calc )

list = [pepperoni_calc, chicken_calc, extra_cheese_calc, mushrooms_calc, spinach_calc, olives_calc] list.sort() print(" Popular topping percentage:", list[-1],"%") print("Unpopular topping percentage:", list[0],"%")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions