# Constants for the menu choices # Constants for the menu choices PURCHASE_ADULT = 1 PURCHASE_CHILD = 2 PURCHASE_MOUSE_EARS = 3 PURCHASE_PARKING = 4 PURCHASE_FOOD = 5 PRINT_ALL = 6 CALC_TOTAL = 7 QUIT_CHOICE = 8 # The main function. def main(): # The choice variable controls the loop # and holds the user's menu choice. choice = 0 costAdult=0 costKid=0 costEars=0 costPark=0 costFood = 0 while choice != QUIT_CHOICE: # display the menu. display_menu() # Get the user's choice. choice = int(input('Enter your choice: ')) # Perform the selected action. if choice == PURCHASE_ADULT: costAdult = purchaseAdult() elif choice == PURCHASE_CHILD: costKid = purchaseKid() elif choice == PURCHASE_MOUSE_EARS: costEars = purchaseEars() elif choice == PURCHASE_PARKING: costPark = purchaseParking(); elif choice == PURCHASE_FOOD: costFood = purchaseFood() elif choice == PRINT_ALL: printIt(costAdult,costKid,costEars,costPark,costFood) elif choice == CALC_TOTAL: calcTotal(costAdult,costKid,costEars,costPark,costFood) elif choice == QUIT_CHOICE: print('Exiting the program...') else: print('Error: invalid selection.') # The display_menu function displays a menu. def display_menu(): print(' MENU') print('1) Purchase adult tickets') print('2) Purchase child tickets') print('3) Purchase cool mouse ears') print('4) Purchase parking') print('5) Purchase food') print('6) Print information') print('7) Calculate total') print('8) Quit') #purchaseAdult() method returns how much the adult tickets will cost def purchaseAdult(): COST_EACH = 95.00 # finish this #purhcaseKid() function returns how much the kids tickets will cost def purchaseKid(): COST_KID = 65.00 # finish this #purhcaseKid() function returns how much the kids tickets will cost def purchaseEars(): EAR_COST = 9.00 # finish this # purchaseParking() just returns 25 for parking def purchaseParking(): COST_PARKING = 25 #finish this # purchaseFood() asks for the number of hot dogs and sodas, calculates the total cost # and returns this value def purchaseFood(): COST_DOGS = 12 COST_SODA = 6 print("We have hot dogs ($12.00 each) and soda ($6.00 each) only") #printIt() prints our each individual cost (see sample output def printIt(costA, costK, costE, costP, costF): print() #finish this #calcTotal() calculates and prints the total cost def calcTotal(costA, costK, costE, costP, costF): print() # finish this # Call the main function. main()
# Constants for the menu choices
# Constants for the menu choices
PURCHASE_ADULT = 1
PURCHASE_CHILD = 2
PURCHASE_MOUSE_EARS = 3
PURCHASE_PARKING = 4
PURCHASE_FOOD = 5
PRINT_ALL = 6
CALC_TOTAL = 7
QUIT_CHOICE = 8
# The main function.
def main():
# The choice variable controls the loop
# and holds the user's menu choice.
choice = 0
costAdult=0
costKid=0
costEars=0
costPark=0
costFood = 0
while choice != QUIT_CHOICE:
# display the menu.
display_menu()
# Get the user's choice.
choice = int(input('Enter your choice: '))
# Perform the selected action.
if choice == PURCHASE_ADULT:
costAdult = purchaseAdult()
elif choice == PURCHASE_CHILD:
costKid = purchaseKid()
elif choice == PURCHASE_MOUSE_EARS:
costEars = purchaseEars()
elif choice == PURCHASE_PARKING:
costPark = purchaseParking();
elif choice == PURCHASE_FOOD:
costFood = purchaseFood()
elif choice == PRINT_ALL:
printIt(costAdult,costKid,costEars,costPark,costFood)
elif choice == CALC_TOTAL:
calcTotal(costAdult,costKid,costEars,costPark,costFood)
elif choice == QUIT_CHOICE:
print('Exiting the program...')
else:
print('Error: invalid selection.')
# The display_menu function displays a menu.
def display_menu():
print(' MENU')
print('1) Purchase adult tickets')
print('2) Purchase child tickets')
print('3) Purchase cool mouse ears')
print('4) Purchase parking')
print('5) Purchase food')
print('6) Print information')
print('7) Calculate total')
print('8) Quit')
#purchaseAdult() method returns how much the adult tickets will cost
def purchaseAdult():
COST_EACH = 95.00
# finish this
#purhcaseKid() function returns how much the kids tickets will cost
def purchaseKid():
COST_KID = 65.00
# finish this
#purhcaseKid() function returns how much the kids tickets will cost
def purchaseEars():
EAR_COST = 9.00
# finish this
# purchaseParking() just returns 25 for parking
def purchaseParking():
COST_PARKING = 25
#finish this
# purchaseFood() asks for the number of hot dogs and sodas, calculates the total
cost
# and returns this value
def purchaseFood():
COST_DOGS = 12
COST_SODA = 6
print("We have hot dogs ($12.00 each) and soda ($6.00 each) only")
#printIt() prints our each individual cost (see sample output
def printIt(costA, costK, costE, costP, costF):
print()
#finish this
#calcTotal() calculates and prints the total cost
def calcTotal(costA, costK, costE, costP, costF):
print()
# finish this
# Call the main function.
main()
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 8 images