Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import menu
- import datetime
- # Print a welcome message
- # Print the menu
- # Allow user to enter items from the menu
- # Add them up and print a receipt.
- def welcome():
- print"Welcome to your till, start by entering the items 1 at a time\n"
- A = menu.Menu("A", "Chicken Strips","3.50",3.5)
- B = menu.Menu("B", "French Fries","2.50",2.5)
- C = menu.Menu("C", "Hamburger","4.00",4)
- D = menu.Menu("D", "Hotdog","3.50",3.5)
- E = menu.Menu("E", "Large Drink","1.75",1.75)
- F = menu.Menu("F", "Medium Drink","1.50",1.5)
- G = menu.Menu("G", "Milk Shake","2.25",2.25)
- H = menu.Menu("H", "Salad","3.75",3.75)
- I = menu.Menu("I", "Small Drink","1.25",1.25)
- print A.price
- def enter_items():
- price = 0.0
- input = True
- today = datetime.date.today()
- receipt = open("D:\Python\Till\Receipt.txt", "w")
- receipt.write("MENU RECEIPT\n\n")
- print(today)
- while input == True:
- item = raw_input("\nEnter item letter: ")
- if item.upper() == "A":
- print A.name
- receipt.write(A.name)
- receipt.write(" | ")
- receipt.write(A.text_price)
- receipt.write("\n")
- price = price + A.price
- print("Sub-Total = %.2f" % price)
- elif item.upper() == "B":
- print B.name
- receipt.write(B.name)
- receipt.write(" | ")
- receipt.write(B.text_price)
- receipt.write("\n")
- price += B.price
- print("Sub-Total = %.2f" % price)
- elif item.upper() == "C":
- print A.name
- receipt.write(C.name)
- receipt.write(" | ")
- receipt.write(C.text_price)
- receipt.write("\n")
- price += C.price
- print("Sub-Total = %.2f" % price)
- elif item.upper() == "D":
- print A.name
- receipt.write(D.name)
- receipt.write(" | ")
- receipt.write(D.text_price)
- receipt.write("\n")
- price = price + D.price
- print("Sub-Total = %.2f" % price)
- elif item.upper() == "E":
- print A.name
- receipt.write(E.name)
- receipt.write(" | ")
- receipt.write(E.text_price)
- receipt.write("\n")
- price = price + E.price
- print("Sub-Total = %.2f" % price)
- elif item.upper() == "F":
- print A.name
- receipt.write(F.name)
- receipt.write(" | ")
- receipt.write(F.text_price)
- receipt.write("\n")
- price = price + F.price
- print("Sub-Total = %.2f" % price)
- elif item.upper() == "G":
- print G.name
- receipt.write(G.name)
- receipt.write(" | ")
- receipt.write(G.text_price)
- receipt.write("\n")
- price = price + G.price
- print("Sub-Total = %.2f" % price)
- elif item.upper() == "H":
- print H.name
- receipt.write(H.name)
- receipt.write(" | ")
- receipt.write(A.text_price)
- receipt.write("\n")
- price = price + H.price
- print("Sub-Total = %.2f" % price)
- elif item.upper() == "I":
- print I.name
- receipt.write(I.name)
- receipt.write(" | ")
- receipt.write(I.text_price)
- receipt.write("\n")
- price = price + I.price
- print("Sub-Total = %.2f" % price)
- elif item.upper() == "P":
- receipt.write("\n\n TOTAL | %.2f" % price)
- receipt.close()
- input = False
- else:
- print"You have entered an incorrect item.\nPlease try again."
- def show_receipt():
- with open("D:\Python\Till\Receipt.txt", "r") as receipt:
- data=receipt.read()
- print("\n\n"+data)
- receipt.close()
- welcome()
- enter_items()
- show_receipt()
- #######################################################################################################################################
- class Menu():
- def __init__(self, key, name, text_price, price):
- self.key = key
- self.name = name
- self.text_price = text_price
- self.price = price
- print "[",key,"]", name, price
- def print_menu(self):
- print"[A] Chicken Strips - $3.50"
- print"[B] French Fries - $2.50"
- print"[C] Hamburger - $4.00"
- print"[D] Hotdog - $3.50"
- print"[E] Large Drink - $1.75"
- print"[F] Medium Drink - $1.50"
- print"[G] Milk Shake - $2.25"
- print"[H] Salad - $3.75"
- print"[I] Small Drink - $1.25"
- print"[P] to print receipt"
Advertisement
Add Comment
Please, Sign In to add comment