Advertisement
Guest User

Untitled

a guest
Jun 17th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <cs50.h>
  3.  
  4. int main(void)
  5. {
  6. float change;
  7. float quarter = 0.25;
  8. float dime = 0.10;
  9. float nickel = 0.05;
  10. float penny = 0.01;
  11. int coinCount = 0;
  12.  
  13.  
  14. printf("Change: ");
  15. change = GetFloat();
  16.  
  17. while (change >= quarter)
  18. {
  19. change -= quarter;
  20. coinCount ++;
  21. }
  22.  
  23.  
  24. while (change >= dime)
  25. {
  26. change -= dime;
  27. coinCount ++;
  28. }
  29.  
  30.  
  31. while (change >= nickel)
  32. {
  33. change -= nickel;
  34. coinCount ++;
  35. }
  36.  
  37.  
  38. while (change >= penny)
  39. {
  40. change -= penny;
  41. coinCount ++;
  42. }
  43.  
  44.  
  45. printf("%d\n", coinCount);
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement