Advertisement
joseleeph

Untitled

Nov 27th, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. from cs50 import get_float
  2. def main():
  3. n = get_float("Cash owed: ")
  4. changecalc(n)
  5. #while (n>0):
  6. #changecalc(n)
  7. def changecalc(num):
  8. num = get_float("cash owed: ")
  9.  
  10. quarters = 0
  11. dimes = 0
  12. nickels = 0
  13. pennies = 0
  14. total = 0
  15. #num = get_float("Cash owed: )./
  16. rnum = round(num*100)
  17. while rnum > 0:
  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