Question

In: Computer Science

Write a Python program that simulates a restaurant ordering system where it stores multiple orders of...

Write a Python program that simulates a restaurant ordering system where it stores multiple orders of a dish and the price for each order stored into a list. The program will then print the receipt which includes list of orders and their price along with the subtotal before tax, the tax amount, and the final total. Also include tip suggestions for 10%, 15% and 20%. Use the format specifiers to make the price line up and the tip only 2 decimal points.

Example:

Welcome to No 2. Kitchen

Order

Lt. Tso Chicken                 $ 17.50

Half Century Eggs            $   2.50

Durian ice cream               $   5.00

=========================

Subtotal                             $ 25.00

Tax (7%)                           $   1.75

=========================

Total                                  $ 26.75

Tip suggestion

10% : $2.67  

15% : $4.01

20% : $5.35

Solutions

Expert Solution

A sample python program which demonstates the above use case scenario is as follows:

(As there were no constrainst given for what to include in the restaurant food menu and pricings, I have prepared a universal template for you. Change the food items or the restaurant name and the other variable parameters as per your convenience)

menu = { "burger":5.00, "fries":3.50, "drink":1.00 }
order = { "burger":0, "fries":0, "drink":0 }
subtotal=0.0

def orderFrom():
    global subtotal
    while True:
        print ("What you want to order today?\n1. Burger\n2. Fries\n3. Drink\n4. Done Ordering (Give me Receipt)")
        choice = int(input("Your Choice"))
        if choice==1:
            order["burger"]+=1
            subtotal=subtotal + menu["burger"]
        elif choice==2:
            order["fries"]+=1
            subtotal+=menu["fries"]
        elif choice==3:
            order["drink"]+=1
            subtotal+=menu["drink"]
        elif choice==4:
            printReceipt()
            break
        else:
            print("Wrong Input")

def printReceipt():
    global subtotal
    salesTax=7
    total=subtotal+(0.07*subtotal)
    print("\nYou ordered : ")
    print("\n",order["burger"]," Burger(s) : $","{:.2f}".format(order["burger"]*menu["burger"]))
    print("\n",order["fries"]," Frie(s) : $","{:.2f}".format(order["fries"]*menu["fries"]))
    print("\n",order["drink"]," Drink(s) : $","{:.2f}".format(order["drink"]*menu["drink"]))
    print("\n=========================")
    print("\nSubtotal : $","{:.2f}".format(subtotal))
    print("\nTax (7%) : $", "{:.2f}".format(0.07*subtotal))
    print("\n=========================")
    print("Total Cost : $","{:.2f}".format(total))
    print("Tip Suggestion\n 10% : $","{:.2f}".format(0.1*total),"\n 15% : $","{:.2f}".format(0.15*total),"\n 20% : $","{:.2f}".format(0.2*total))
    print("Visit Us Again")
    order["burger"]=0
    order["fries"]=0
    order["drink"]=0
    subtotal=0.0
    getOrderFunc()

def getOrderFunc():
    print("Welcome to ABC Restaurant\n")
    getOrder = input ("Do you want to order something(Y/N)?")
    if getOrder=='Y'or getOrder=='y':
        orderFrom()
    else:
        print ("Thanks for coming")
        exit()

getOrderFunc()

Output:

Hope you find the implementation helpful and insightful.

Keep Learning!


Related Solutions

Write a python program that simulates a simple dice gambling game. The game is played as...
Write a python program that simulates a simple dice gambling game. The game is played as follows: Roll a six sided die. If you roll a 1, 2 or a 3, the game is over. If you roll a 4, 5, or 6, you win that many dollars ($4, $5, or $6), and then roll again. With each additional roll, you have the chance to win more money, or you might roll a game-ending 1, 2, or 3, at which...
You will write a program using Python that simulates an Automatic Teller Machine (ATM). For this...
You will write a program using Python that simulates an Automatic Teller Machine (ATM). For this program, your code can have user defined functions (but not required), the program must not call on any external functions or modules to handle any of the input, computational, and output requirements. Requirements: There is a customer with the following credential and can only access the system if the Access Code is correct: • Name: Peter Parker, Access Code: 2222 • When the program...
I need to write a program in python for a restaurant. The program should let the...
I need to write a program in python for a restaurant. The program should let the user enter a meal number, then it should display the meal name, meal price, and meal calories. Also, needs the appropriate output if the user enters an invalid meal number. I am supposed to use a dictionary, but my problem is it keeps giving me an error and telling me my menu is not defined. Not sure what I am doing wrong. print ("Welcome...
Python program that simulates playing a game where a US penny (radius of 3/8 inches) is...
Python program that simulates playing a game where a US penny (radius of 3/8 inches) is tossed into a board with a 1-inch by 1-inch square. The player wins only if the penny lands entirely within the square. Estimate the probability of winning by repeating the game 1,000 times. Record the estimate of the winning chance as a comment. Also, find the winning probability. Please use comments to better explain :)
Write a program that simulates the flipping of a coin n times, where n is specified...
Write a program that simulates the flipping of a coin n times, where n is specified by the user. The program should use random generation to flip the coin and each result is recorded. Your program should prompt the user for the size of the experiment n, flip the coin n times, display the sequence of Heads and Tails as a string of H (for Head) and T (for Tail) characters, and display the frequencies of heads and tails in...
Please write in Python code Write a program that stores the following data in a tuple:...
Please write in Python code Write a program that stores the following data in a tuple: 54,76,32,14,29,12,64,97,50,86,43,12 The program needs to display a menu to the user, with the following 4 options: 1 – Display minimum 2 – Display maximum 3 – Display total 4 – Display average 5 – Quit Make your program loop back to this menu until the user chooses option 5. Write code for all 4 other menu choices
Q- Below is a project requirement for Online ordering system for fast food restaurant(where customer order...
Q- Below is a project requirement for Online ordering system for fast food restaurant(where customer order through app/online) Object-oriented design project: Table of Contents 1- Introduction; 2- Project Plan; 3- Functional Specifications (including descriptions of Actors/Roles; Business Rules; 3.1- Use-Case Diagrams with Use-Case descriptions; Examples of Class Diagrams (related to particular Use Cases); 3.2- Examples of Object Diagrams [related to the selected Class Diagrams]; 3.3- Examples of Sequence Diagrams; 3.4- Examples of Collaboration or Communication Diagrams; 3.5- Examples of State-Chart...
Write a program in python that reads the elements of a set from the keyboard, stores...
Write a program in python that reads the elements of a set from the keyboard, stores them in a set, and then determines its powerset. Specifically, the program should repeatedly ask the user: Enter one more element ? [Y/N] If the user answers Y then an new element is read from the keyboard: Enter the new element in the set: This cycle continues until the user answers N to the first question. At that point the program shall compute the...
Write a Python program that prompts the user to enter a list of words and stores...
Write a Python program that prompts the user to enter a list of words and stores in a list only those words whose first letter occurs again within the word (for example, 'Baboon'). The program should display the resulting list..................please explain step by step
PYTHON BEGINNER Problem Write a program which, given a number, simulates rolling a pair of six-sided...
PYTHON BEGINNER Problem Write a program which, given a number, simulates rolling a pair of six-sided dice that number of times. The program should keep track of how many times each possible sum comes up using a list. The list's first element should contain how many times a total of 2 was rolled, the second should contain how many times a total of 3 was rolled, and so on all the way through to 12. When all rolls are complete,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT