joseleeph

Untitled

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