Advertisement
joseleeph

Untitled

Nov 27th, 2020
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <cs50.h>
  2. #include <stdio.h>
  3. #include <math.h>
  4.  
  5. int main(void)
  6. {
  7.  
  8. int rf;
  9. int dollars = 0;
  10. int quarters = 0;
  11. int dimes = 0;
  12. int nickels = 0;
  13. int pennies = 0;
  14. int total = 0;
  15.  
  16. //printf("please enter the amount of change needed\n"); //printf1
  17. do
  18. {
  19. float f = get_float("Cash owed: ");
  20. rf = round(f*100);
  21. if (rf/25>=0)
  22. {
  23. quarters = rf/25;
  24. rf %= 25;
  25. }
  26.  
  27.  
  28. if (rf/10 >=0)
  29. {
  30. dimes = rf/10;
  31. rf %= 10;
  32. }
  33. if (rf/5>=0)
  34. {
  35. nickels = rf/5;
  36. rf %= 5;
  37. }
  38. if (rf/1 >=0)
  39. {
  40. pennies = rf/1;
  41. rf %= 1;
  42. }
  43. if (rf<0)
  44. {
  45. printf("Please enter a positive number:\n");
  46. }
  47. //total = dimes + pennies + nickels + quarters;
  48. }
  49. while (rf > 0);
  50. total = dimes + pennies + nickels + quarters;
  51. printf("%i",total);
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement