- Code: Select all
`# Menu`

def menu():

"""provides a menu for a restaurant"""

items = [("H", "Hamburger", "$1.29"), ("O", "Onion Rings", "$1.09"), ("C", "Cheeseburger", "$1.49"),

("S", "Small Drink", "$0.79"), ("F", "Fries", "$0.99"), ("L", "Large Drink", "$1.19")]

for x in items:

letter, name, prices = x

print letter, "\t", name, prices

print "A\tEnd Order"

print "R\tReport of Sales"

# Input Function

def input():

"""user inputs what they want"""

choice = "again"

subtotal = 0

htotal = 0

ototal = 0

ctotal = 0

stotal = 0

ftotal = 0

ltotal = 0

while choice.upper() != "A" and choice.upper() != "R":

choice = raw_input("\nEnter a letter that corresponds to what you would like to order: ")

if choice.upper() == "H":

print "Hamburger\t$1.29"

subtotal = subtotal + 1.29

htotal = htotal + 1

elif choice.upper() == "O":

print "Onion Rings\t$1.09"

subtotal = subtotal + 1.09

ototal = ototal + 1

elif choice.upper() == "C":

print "Cheeseburger\t$1.49"

subtotal = subtotal + 1.49

ctotal = ctotal + 1

elif choice.upper() == "S":

print "Small Drink\t$0.79"

subtotal = subtotal + .79

stotal = stotal + 1

elif choice.upper() == "F":

print "Fries\t$0.99"

subtotal = subtotal + .99

ftotal = ftotal + 1

elif choice.upper() == "L":

print "Large Drink\t$1.19"

subtotal = subtotal + 1.19

ltotal = ltotal + 1

elif choice.upper() == "A":

subtotal = subtotal

else:

print "Please enter a correct choice."

grandtotal = htotal + ototal + ctotal + stotal + ftotal + ltotal

return choice, subtotal, htotal, ototal, ctotal, stotal, ftotal, ltotal, grandtotal

#calc function

def calc(choice, subtotal, htotal, ototal, ctotal, stotal, ftotal, ltotal, grandtotal):

"""calculate"""

tax = subtotal * .05

total = subtotal + tax

print "Subtotal: ", subtotal

print "Tax: ", tax

print "Total: $", total

amount = float(raw_input("\nEnter the amount collected: "))

if amount >= total:

change = amount - total

print "Change: $", change

elif amount < total:

amount = float(raw_input("That is not enough money. Please reenter the amount collected: "))

change = amount - total

print "Change: $", change

return tax

# report function

def report(choice, subtotal, htotal, ototal, ctotal, stotal, ftotal, ltotal, grandtotal, tax):

"""displays the report of sales"""

print "Item\t\t\tQuantity\tSales"

print "Hamburgers\t\t", htotal, "\t\t", htotal * 1.29

print "Cheeseburgers\t\t", ctotal, "\t\t", ctotal * 1.49

print "Fries\t\t\t", ftotal, "\t\t", ftotal * .99

print "Onion Rings\t\t", ototal, "\t\t", ototal * 1.09

print "Small Drink\t\t", stotal, "\t\t", stotal * .79

print "Large Drink\t\t", ltotal, "\t\t", ltotal * 1.19

print

print "Total Sales for Day:\t\t\t", grandtotal

print "Total Tax for Day:\t\t\t", grandtotal * tax

print "Total:\t\t\t\t\t", (grandtotal * tax) + grandtotal

# main scope

choice = "yes"

while choice == "yes":

menu()

choice, subtotal, htotal, ototal, ctotal, stotal, ftotal, ltotal, grandtotal = input()

if choice.upper() == "A":

tax = calc(choice, subtotal, htotal, ototal, ctotal, stotal, ftotal, ltotal, grandtotal)

if choice.upper() == "R":

report(choice, subtotal, htotal, ototal, ctotal, stotal, ftotal, ltotal, grandtotal, tax)

choice = raw_input("\nWould you like to enter a new customer(yes/no)? ")