Created
May 18, 2022 02:49
-
-
Save dasunsucharith/2fd20268375211b4d814fa95fccd65ad to your computer and use it in GitHub Desktop.
CS50 2022 psets6 Cash Problem Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TODO | |
from cs50 import get_float | |
# keep track of coins used | |
count = 0 | |
while True: | |
change = get_float("Change owned: ") | |
if change > 0: | |
break | |
# round up to the nearest whole number | |
cent = round(change * 100) | |
while cent >= 25: | |
cent = cent - 25 | |
count += 1 | |
while cent >= 10: | |
cent = cent - 10 | |
count += 1 | |
while cent >= 5: | |
cent = cent - 5 | |
count += 1 | |
while cent >= 1: | |
cent = cent - 1 | |
count += 1 | |
print(count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment