Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from cs50 import get_float
- def main():
- num = get_float("Cash owed")
- changecalc(num)
- def changecalc(num):
- dollars = 0
- quarters = 0
- dimes = 0
- nickels = 0
- pennies = 0
- total = 0
- #num = get_float("Cash owed")
- rnum = round(num)
- while rnum < 0:
- if rnum\25 >= 0:
- quarters = rnum/25
- rnum %= 25
- if rnum\10 >= 0:
- dimes = rnum/10
- rnum %= 10
- if rnum\5 >= 0:
- nickels = rnum/5
- rnum %= 5
- if rnum\1 >= 0:
- pennies = rnum/1
- rnum %= 1
- if rf < 0:
- print("Please enter a positive number:")
- total = dimes + pennies + nickels + quarters
- return total
- main()
Advertisement
Add Comment
Please, Sign In to add comment