joseleeph

Untitled

Nov 27th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. from cs50 import get_float
  2.  
  3. def main():
  4. num = get_float("Cash owed")
  5. changecalc(num)
  6. def changecalc(num):
  7. dollars = 0
  8. quarters = 0
  9. dimes = 0
  10. nickels = 0
  11. pennies = 0
  12. total = 0
  13. #num = get_float("Cash owed")
  14. rnum = round(num)
  15. while rnum < 0:
  16. if rnum\25 >= 0:
  17. quarters = rnum/25
  18. rnum %= 25
  19. if rnum\10 >= 0:
  20. dimes = rnum/10
  21. rnum %= 10
  22. if rnum\5 >= 0:
  23. nickels = rnum/5
  24. rnum %= 5
  25. if rnum\1 >= 0:
  26. pennies = rnum/1
  27. rnum %= 1
  28. if rf < 0:
  29. print("Please enter a positive number:")
  30. total = dimes + pennies + nickels + quarters
  31. return total
  32. main()
Advertisement
Add Comment
Please, Sign In to add comment