Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include "cs50.h"
  4.  
  5. int main(void)
  6. {
  7. float n;
  8. int count = 0.0, amount;
  9. do
  10. {
  11. printf("Change Owed:\n");
  12. n = GetFloat();
  13. }
  14. while (n > 0.0);
  15.  
  16.  
  17. n *= 100.0;
  18. amount = (int) round(n);
  19. while (amount >= 25)
  20. {
  21. count++;
  22. amount -= 25;
  23. }
  24. while (amount >= 10)
  25. {
  26. count++;
  27. amount -= 10;
  28. }
  29.  
  30. while (amount >= 5)
  31. {
  32. count++;
  33. amount -= 5;
  34. }
  35.  
  36. while (amount >= 1)
  37. {
  38. count++;
  39. amount -= 1;
  40. }
  41.  
  42. printf("%d\n", count);
  43.  
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement