Your menu will still have the following options: Make Change High Card Quit Your
ID: 3789973 • Letter: Y
Question
Your menu will still have the following options: Make Change High Card Quit Your program will display the menu, prompt for and read the user's option. Then your program will branch based on the option: If the user chooses option 1. play the "make change" game If the user chooses option 2. displays the message "High Card is coming soon." If the user chooses option 3, you do nothing - your program should just end naturally. If the user chooses an invalid option (option 3) your program should display the message "Invalid option" and terminate naturally. Do not try to re-prompt for input. The "make change" game does the following: Allow a clerk to enter the amount of money a customer owes for a purchase and the amount of money the customer paid. This function should calculate and display the amount of change. Then break it down into the number of dollars, quarters, dimes, nickels and pennies to return to the customer. For example: If the amount owed is $3.16 and the amount paid is $20. you program should display the change due as: $16.84 16 dollars 3 quarters 1 nickel 4 pennies You decide exactly how to display the change, but your output should include all the information above. Display the total amount of change due to two decimal places consistent with money amounts. The number of each denomination to be paid back to the customer will be integers. Display an appropriate message when the amount paid is less than the amount owed, do not try to ask for additional money, just display the message.Explanation / Answer
The following code gives you the required functionality
# your code goes here
print('1. Make Change')
print('2. High Card')
print('3. Quit')
option = int(input('Choose your option: '))
if option == 1:
#wait
owe = float(input('Enter the money a customer owe: '))
paid = float(input('Enter the money customer paid: '))
res = paid - owe
print(str(int(res)) + ' dollars')
res = (res - int(res))*100
print(str(int(res//25)) + ' quarters')
res = res % 25
print(str(int(res//5)) + ' nickels')
res = res % 5
print(str(int(round(res))) + ' pennies')
elif (option == 2):
print('High Card is coming soon.')
elif (option == 3):
#do nothing
pass
else:
print('Invalid option')
Input:
1
3.16
20
Output:
1. Make Change
2. High Card
3. Quit
Choose your option: Enter the money a customer owe: Enter the money customer paid: 16 dollars
3 quarters
1 nickels
4 pennies
Code's link:
http://ideone.com/dEK9Xe
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.