Guest User

Untitled

a guest
Jan 17th, 2014
800
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <cs50.h>
  2. #include <math.h>
  3. #include <stdio.h>
  4.  
  5. int main (void)
  6. {
  7.  
  8. float dollars;
  9. int quarters = 0;
  10. int dimes = 0;
  11. int penny = 0;
  12. int nickel = 0;
  13. int counter = 0;
  14.  
  15. //a loop to take the user input
  16. do
  17. {
  18. printf("how much change is owed? ");
  19. dollars = GetFloat();
  20.  
  21. }
  22.  
  23.  
  24. while (dollars <= 0 );
  25.  
  26. int cent = round(dollars * 100);
  27.  
  28.  
  29.  
  30. //loops to collect input and give number of coins left.
  31. while (quarters >= 25)
  32. counter++;
  33. quarters = cent - 25;
  34. quarters = cent % 25;
  35.  
  36.  
  37. while(dimes >= 10)
  38. counter++;
  39. dimes = cent - 10;
  40. dimes = cent % 10;
  41.  
  42. while (nickel >= 5)
  43. counter++;
  44. nickel = cent - 5;
  45. nickel = cent % 5;
  46.  
  47.  
  48. //dollars = cent / 5;
  49. nickel = cent % 5;
  50. while (penny >= 1)
  51. counter++;
  52. penny = cent - 1;
  53. penny = cent % 1;
  54.  
  55. printf("i have %d coins\n",counter);
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment