summaryrefslogtreecommitdiff
path: root/wk6/pset/sentimental-cash/cash.py
blob: d3d9bdbd8afb03ccbf4f92d3774066a5ca67a41c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from cs50 import get_float

while True:
    cents = get_float("Change: ")
    if cents > 0:
        break

quarters = cents // 0.25
cents -= quarters * 0.25
cents = round(cents, 2)

dimes = cents // 0.10
cents -= dimes * 0.10
cents = round(cents, 2)

nickels = cents // 0.05
cents -= nickels * 0.05
cents = round(cents, 2)

pennies = cents // 0.01
cents -= pennies * 0.01
cents = round(cents, 2)

coins = quarters + dimes + nickels + pennies
print(int(coins))