Advertisement
joseleeph

Untitled

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