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.
money = int(input("enter total amount of money you have:\t"))
count_dollars = 0
count_quarters = 0
count_dimes = 0
count_nickels = 0
count_pennies = 0
dollar = 100
quarter = 25
dime = 10
nickel = 5
pennie = 1
while(money > 0):
if(money > dollar):
money = money -
dollar
count_dollars += 1
elif(money > quarter):
money = money -
quarter
count_quarters +=
1
elif(money > dime):
money = money -
dime
count_dimes += 1
elif(money > nickel):
money = money -
nickel
count_nickels += 1
elif(money > pennie):
money = money -
pennie
count_pennies += 1
else:
break
print("{} dollars, {} quarters, {} dimes, {} nickels, {}
pennies".format(count_dollars, count_quarters, count_dimes,
count_nickels, count_pennies))
If you have any doubts please comment and please don't dislike.