Question

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

#Python program that display a list of items and its cost to user and then prompt user to enter his/her choice of item.
#the program prompts user to enter choice of items until user enters 0 to stop reading. Then prompt whether discount is #applied and then find the total bill, before and after tax calculation
#main.py

def main():

    #9 % tax rate for staff
    TAX=0.09
    #set constant values
    CUPERTINO_COST=5
    COFFEE=4
    SOFTDRINK=3
    COCONUT=5
    FRENCHFRIES=10
    #set zero values
    total=0
    taxamount=0
    totalbill=0
    #call getChoice function
    choice=getChoice()

    while choice!=0:
        if choice==1:
            total=total+CUPERTINO_COST
        elif choice==2:
            total=total+COFFEE
        elif choice==3:
            total=total+SOFTDRINK
        elif choice==4:
            total=total+COCONUT
        elif choice==5:
            total=total+FRENCHFRIES
        choice = getChoice()

    #Get user value for type of person
    type=int(input('Enter 1 for student or 2 for staff :'))
    if type==1:
        taxamount = 0
    elif type==2:
        #calculate the 9% tax amount on total
        taxamount = total * TAX
    #calculate total bill amount
    totalbill=total+taxamount

    #print total, tax and total bill value
    print('Cost of the items : ',total)
    print('Tax amount : ',taxamount)
    print('Total price after tax : ',totalbill)

#Function that display the items to user
def displayMenu():
    print('1.Cupertino ---5$')
    print('2.Coffe ---4$')
    print('3.Soft drink ---3$')
    print('4.Coconut ---5$')
    print('5.French-fries ---10$')
#Function that prompts for user choice
def getChoice():
    displayMenu()
    choice=int(input('Enter choice [1-5] or 0 to exit: '))
    if (choice<0 or choice>5):
        print('Invalid choice')
    else:
        return choice
#Function that calls main
if __name__ == "__main__":
    main()

------------------------------------------------------------------------------------

Sample Output:

1.Cupertino ---5$
2.Coffe ---4$
3.Soft drink ---3$
4.Coconut ---5$
5.French-fries ---10$
Enter choice [1-5] or 0 to exit: 1
1.Cupertino ---5$
2.Coffe ---4$
3.Soft drink ---3$
4.Coconut ---5$
5.French-fries ---10$
Enter choice [1-5] or 0 to exit: 1
1.Cupertino ---5$
2.Coffe ---4$
3.Soft drink ---3$
4.Coconut ---5$
5.French-fries ---10$
Enter choice [1-5] or 0 to exit: 0
Enter 1 for student or 2 for staff :2
Cost of the items : 10
Tax amount : 0.8999999999999999
Total price after tax : 10.9

Add a comment
Know the answer?
Add Answer to:
Simple python assignment Write a menu-driven program for Food Court. (You need to use functions!) Display...
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
  • 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...

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

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

  • In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a...

    In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a program that asks the user to enter an integer value. Your program will then display that integer back to the user. Your program should include a function called getInteger that requests an integer value from the user and returns that value back to the caller. Your main () function will call the function getInteger and will then display the value returned by that function....

  • (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...

  • Write a C++ program that will display the following menu and work accordingly. A menu that...

    Write a C++ program that will display the following menu and work accordingly. A menu that will display the following choices and uses functions to carry out the calculations: 1. Call a function named classInfo() to ask the user the number of students and exams in a course. 2. Call a function getGrade() that will get the information from classInfo() and asks the user to enter the grades for each student. 3. Call a function courseGrade() to display the average...

  • Develop a system flowchart and then write a menu-driven C++ program that uses user-defined functions arrays,...

    Develop a system flowchart and then write a menu-driven C++ program that uses user-defined functions arrays, and a random number generator. Upon program execution, the screen will be cleared and the menu shown below will appear at the top of the screen and centered. The menu items are explained below. Help Smallest Quit H or h ( for Help ) option will invoke a function named help() which will display a help screen. The help screen(s) should guide the user...

  • In this program, you will be using C++ programming constructs, such as overloaded functions. Write a...

    In this program, you will be using C++ programming constructs, such as overloaded functions. Write a program that requests 3 integers from the user and displays the largest one entered. Your program will then request 3 characters from the user and display the largest character entered. If the user enters a non-alphabetic character, your program will display an error message. You must fill in the body of main() to prompt the user for input, and call the overloaded function showBiggest()...

  • 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