In: Computer Science
Write code that classifies a given amount of money (which you store in a variable named amount), specified in cents, as greater monetary units. Your code lists the monetary equivalent in dollars (100 ct), quarters (25 ct), dimes (10 ct), nickels (5 ct), and pennies (1 ct). Your program should report the maximum number of dollars that fit in the amount, then the maximum number of quarters that fit in the remainder after you subtract the dollars, then the maximum number of dimes that fit in the remainder after you subtract the dollars and quarters, and so on for nickels and pennies. The result is that you express the amount as the minimum number of coins needed. Please show me how to do it in the jupyter notebook.
Thanks for the question. Below is the code you will be needing Let me know if you have any doubts or if you need anything to change. Thank You !! ===========================================================================
amount = float(input('Enter amount: ')) # convert amount to all pennies by x 100 amount = amount * 100 # number of dollar than fit in that amount is amount / 100 dollars = amount // 100 # doing integer division dont need the fraction part pennies_left = amount - dollars * 100 # number of quarter than fit is pennies_left//25 quarters = pennies_left // 25 pennies_left = pennies_left - quarters * 25 # number of dimes that can fit is dimes//10 dimes = pennies_left // 10 pennies_left = pennies_left - dimes * 10 # number of nickels that can fit pennies_left//5 nickels = pennies_left // 5 pennies_left = pennies_left - nickels * 5 print('Exchange:') print('{} X $1 bill'.format(round(dollars))) print('{} X quarters'.format(round(quarters))) print('{} X dimes'.format(round(dimes))) print('{} X nickels'.format(round(nickels))) print('{} X pennies'.format(round(pennies_left)))