Homework 12 - UMBC-CMSC104/General GitHub Wiki

Drink menu

For this project, you're to make a drink menu that allows the user to select a number of drinks. When the user is done adding drinks to their tab, you can print out a receipt. Please name this drink_menu.py. Use Python for this program.

If the user has more than 3 alcoholic drinks, please add the cost of a taxi cab to the bill ($40.00).

The program should use functions and arrays appropriately.

Here's some example output:

Welcome to Mike's Tavern!
We have the following on tap:
Beer    - $3.00
Wine    - $4.00
Whiskey - $5.00
Coca Cola    - $2.00
Orange Juice - $3.00
Apple Juice  - $3.00
Water        - $0.00

What would you like? beer
Would you like anything else? beer
Would you like anything else? wine
You've had a lot of alcohol -- we'll call you a cab.
Would you like anything else? water
Would you like anything else? coca cola
Would you like anything else? no

Thank you.  Here's your receipt:

Beer - $3.00
Beer - $3.00
Wine - $4.00
Water - $0.00
Coca Cola - $2.00
Taxi Cab - $40.00
-----------------
Total: $52.00

To submit:

submit cs104_wilson hw12 drink_menu.py

Notes

Case insensitive string compare can be done using the string's "lower" function:

user_input = raw_input()
some_string = "A String"

if some_string.lower() == user_input.lower():
    print "The strings are the same!"

lower will convert a string entirely into lower case. If you lower case both sides of an if statement, you can guarantee case insensitivity.

Extra credit opportunities

  • Consolidate entries on the receipt such that they show the number of each order entered.

For example, the receipt above would look like:

Beer x 2 - $6.00
Wine - $4.00
Water - $0.00
Coca Cola - $2.00
Taxi Cab - $40.00
-----------------
Total: $52.00
  • Sort the receipt alphabetically.