In: Computer Science
Need this program Using Classes , Objects, Save to file, and Printbill Simple python assignment
Write a menu-driven program for Food Court. (You need to use functions!) Display the food menu to a user (Just show the 5 options' names and prices - No need to show the Combos or the details!) Ask the user what he/she wants and how many of it. (Check the user inputs) AND Use strip() function to strip your inputs. Keep asking the user until he/she chooses the end order option. (You can pass quantity1, quantity2, quantity3, quantity4 & quantity5 to save the quantities of the orders) Calculate the price. Ask the user whether he/she is a student or a staff. There is no tax for students and 9% tax for staffs. Add the tax price to the total price. Tax Cupertino 9.000% Santa Clara Display the bill to the user. The bill includes: The food items The quantities The cost of them The total before tax Tax amount Total price after tax You can have your own design but you need to have a main function and get started from the main function. For example: def main(): displayMenu() . . displayBill(..) main() or if __name__ == "__main__": main() The name of functions also up to your design but they should show what the functions do. Only display 2 decimal points when displaying all the numbers. Put at least two outputs (results after you run your code) at the end of your code as a multi-line comment. Don't forget to put your name and a short description of your code on the top on your code. Don't forget to test your code with Positive and Negative Testing! (For more information see this page Testing)
code
solution
//output
//copyable code
# display menu
def menu_show(Items_menu):
i1 = 1
print("Item Name\t Price")
for menu_Item in Items_menu:
print(str(i1) + ". " + str(menu_Item[0]) + "\t " +
str(menu_Item[1]))
i1 = i1 + 1
# taking inputs
def get_data():
items=["Icecream", "Jaffa cakes","Pot Noodle",
"Frenchfries","Sausage rolls"]
order1 = []
item_name = int(input())
print("Please enter the quantity: ")
Quantity = int(input())
order1.append(items[item_name - 1])
order1.append(Quantity)
return order1
# bill
def computebill(order_List, Items_menu):
print("Are you a student or a staff?")
bill1 = 0.0
tax1 = 0
bill_amt = []
for order in order_List:
for menu_Item in Items_menu:
if order[0] == menu_Item[0]:
bill1 = bill1 + (order[1] * menu_Item[1])
stuOrSta = input()
if stuOrSta == "staff":
tax1 = bill1 * (9 / 100)
else:
tax1 = 0.0
bill_amt.append(bill1)
bill_amt.append(tax1)
return bill_amt
# display bill
def display_bill(order_List, Items_menu, bill_amt):
print("Item Name\t Price\t Quantity")
for order in order_List:
for menu_Item in Items_menu:
if order[0] == menu_Item[0]:
print(str(menu_Item[0]) + "\t " + str(menu_Item[1]) + "\t " +
str(order[1]))
print("Amount: \t\t"+"{:.2f}".format((bill_amt[0])));
print("Tax:\t\t"+"{:.2f} " .format((bill_amt[1])))
total_Amt = bill_amt[0] + bill_amt[1]
print("Amount:\t\t"+"{:.2f} " .format((total_Amt)))
def main():
Items_menu = [["Icecream", 2], ["Jaffa cakes", 3], ["Pot Noodle",
1.75], ["Frenchfries", 1.5], ["Sausage rolls", 2.3]]
order_List = []
while True:
menu_show(Items_menu)
order = get_data()
order_List.append(order)
print("Do you want to place another order? (y/n)")
choice = input()
if choice == "n":
break
bill_amt = computebill(order_List, Items_menu)
display_bill(order_List, Items_menu, bill_amt)
if __name__ == "__main__":
main()