Question

Please help me to do my assignment it should be python. Thank you Write a menu-driven...

Please help me to do my assignment it should be python. Thank you

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)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

from collections import OrderedDict
from string import ascii_uppercase

order={}
user=""
menu_items =[]

#Item class to store details of item like name and price
class Item:
def __init__(self, name, price):
self.name = name
self.price = price
  
def __str__(self):
itemDetail=self.name +(" price: %.2f "%(self.price))
return itemDetail
  
#user function to generate the bill
def generateBill():
print("\n\n\n -----------Bill---------------\n\n\n")
global user
grandTotal=0.0
tax=0.0
for item in order.keys():
itemName=item.name
quantity=order[item]
price=item.price
totalPrice=price*quantity
print (itemName +" : %.2f X %d = %.2f"%(price,quantity,totalPrice))
grandTotal+=totalPrice
  
print ("total price for all item is without Tax = %.2f"%(grandTotal))
  
if user == "student":
tax=0
elif user == "staff":
tax=grandTotal*0.09
print("tax value = %.2f"%(tax))
print("total amount (include tax) = %.2f"%(grandTotal+tax))


#this will add item and their quantity in order dictionary
def addItem(item,quantity):
if item in order:
order[item]+=quantity
else:
order[item]=quantity

#for input of user as student or staff
def getUserDetail():
global user
Done=False
while(not Done):
Done=True
user=raw_input("press A for student and B for staff: ")
user=user.strip()
if user is "A":
user="student"
elif user is "B":
user="staff"
else:
print("wrong input")
Done=False

#initializing the menu of Items
def init():
menu_items.append(Item('The "Big Boy" Burger', 16.99))
menu_items.append(Item('French Fries', 5.99))
menu_items.append(Item('Currie sauce', 19.99))
menu_items.append(Item('Napkins with Chokolates', 10.50))
menu_items.append(Item('Juice Box', 89.01))
menu_items.append(Item('Takeout', 18.99))
  
selection='A'
for item in menu_items :
print selection +" : "+ item.__str__()
selection = chr(ord(selection) + 1)
  
  
def main():

init() #initalizing menu of order
  
Done=False #to check if your end its menu selection
  
#while user not input done this loop will conitinue to take input fro user
while(not Done):
item= str(raw_input("enter the item number or 'done' for exit menu selection: "))
item=item.strip()
if item is "A":
quantity=int(input("enter the quantity: "))
addItem(menu_items[0],quantity)
  
elif item is "B":
quantity=int(input("enter the quantity: "))
addItem(menu_items[1],quantity)
elif item is "C":
quantity=int(input("enter the quantity: "))
addItem(menu_items[2],quantity)
elif item is "D":
quantity=int(input("enter the quantity: "))
addItem(menu_items[3],quantity)
elif item is "E":
quantity=int(input("enter the quantity: "))
addItem(menu_items[4],quantity)
elif item == "done":
Done=True
else:
print("wrong input")
  
getUserDetail()
generateBill()
  

if __name__ == "__main__":
main()

output:

Add a comment
Know the answer?
Add Answer to:
Please help me to do my assignment it should be python. Thank you Write a menu-driven...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Simple python assignment Write a menu-driven program for Food Court. (You need to use functions!) Display...

    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,...

  • This is my assignment in Python. Please help me thank you Design type 1: # Creating an object of ...

    This is my assignment in Python. Please help me thank you Design type 1: # Creating an object of the class "Burger" theOrder = Burger() # calling the main method theOrder.main() # And the class is like: class Burger: # You may need to have a constructor def __init__(self): self._orderDict = {} self._priceBeforeTax = 0 self._priceAfterTax = 0 # you may have the tax rate also as an instance variable. But as I mentioned, you can use your # own...

  • Use a switch statement to build a menu-driven calculator

    ENGR 40 PROGRAMMING ASSIGNMENT MENU-DRIVEN CALCULATOR PROGRAM Use a switch statement to build a menu-driven calculator. Your program should ask the user to choose from a list of ten possible functions (square root, square, natural log, common log, e'x yx, 1/x, sin(x), cos(x), and tan(x). Each choice will correspond to an integer -example: (1) square root, (2) square, etec. Once the person has input a function choice then a switch statement will control the flow of the program- ie. the program...

  • You are to write a program IN C++ that asks the user to enter an item's...

    You are to write a program IN C++ that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: if the an item's wholesale cost is 5.00 and its markup percentage is 100%, then the item's retail price is 10.00 If an item's wholesale cost is 5.00 and its markup percentage is 50%, then the item's retail price is 7.50 Program design specs. You should have 5...

  • It's my python assignment. Thank you You wrote a program to prompt the user for hours...

    It's my python assignment. Thank you You wrote a program to prompt the user for hours and rate per hour to compute gross pay. Also your pay computation to give the employee 1.5 times the hourly rate for hours worked above 40 hours. Enter Hours: 45 Enter Rate: 10 Pay: 475.0 (475 = 40 * 10 + 5 * 15) Rewrite your pay program using try and except so that your program handles non-numeric input gracefully. Enter Hours: 20 Enter...

  • (PYTHON) Write a program that displays the following menu:. , Write Algorithm for Code Geometry Calculator...

    (PYTHON) Write a program that displays the following menu:. , Write Algorithm for Code Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your choice (1 - 4): If the user enters 1, the program should ask for the radius of the circle and then display its area. If the user enters 2, the program should ask for the length and width of...

  • It's my python homework. Not Java. Design type 1: # Creating an object of the class...

    It's my python homework. Not Java. Design type 1: # Creating an object of the class "DeAnzaBurger" theOrder = DeAnzaBurger() # calling the main method theOrder.main() # And the class is like: class DeAnzaBurger: # You may need to have a constructor def __init__(self): self._orderDict = {} self._priceBeforeTax = 0 self._priceAfterTax = 0 # you may have the tax rate also as an instance variable. But as I mentioned, you can use your # own deign.    .... # That...

  • ***********************PLEASE DO NOT COPY AND PASTE OLD SOLUTIONS*************************** C++ Assignment Write a menu driven program with...

    ***********************PLEASE DO NOT COPY AND PASTE OLD SOLUTIONS*************************** C++ Assignment Write a menu driven program with the following options to call a recursive function, which raise x to the power n must work for negative n as well as positive n. ( x − n = 1/ x n ) ask a user for the values of x and n to call a recursive function to add the first n terms of the series 1+1/2+1/3...1/n function output sample: 1+1/2+1/3+1/4+= 2.0833...

  • Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve...

    Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve the following program. -Use Microsoft Visual C++ .NET 2010 Professional compiler using default compiler settings. -Use Microsoft Visio 2013 for developing your flowchart. -Adherence to the ANSI C++  required -Do not use <stdio.h> and <conio.h>. -Do not use any #define in your program. -No goto statements allowed. Upon execution of the program, the program displays a menu as shown below and the user is prompted to make a selection from the menu....

  • Write a Python Program that displays repeatedly a menu as shown in the sample run below....

    Write a Python Program that displays repeatedly a menu as shown in the sample run below. The user will enter 1, 2, 3, 4 or 5 for choosing addition, substation, multiplication, division or exit respectively. Then the user will be asked to enter the two numbers and the result for the operation selected will be displayed. After an operation is finished and output is displayed the menu is redisplayed, you may choose another operation or enter 5 to exit the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT