Advertisement
joseleeph

Untitled

Nov 27th, 2020
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. from cs50 import get_float
  2. def main():
  3. n = get_float("Cash owed")
  4. changecalc(n)
  5. def changecalc(num):
  6. #num = get_float("Cash owed")
  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*100)
  15. while rnum > 0:
  16.  
  17.  
  18. if rnum/25 >= 0:
  19. quarters = rnum/25
  20. rnum %= 25
  21. if rnum/10 >= 0:
  22. dimes = rnum/10
  23. rnum %= 10
  24. if rnum/5 >= 0:
  25. nickels = rnum/5
  26. rnum %= 5
  27. if rnum/1 >= 0:
  28. pennies = rnum/1
  29. rnum %= 1
  30. if rnum < 0:
  31. print("Please enter a positive number:")
  32. #changecalc()
  33. total = dimes + pennies + nickels + quarters
  34. return total
  35. #return total
  36. #print(total)
  37. main()
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement