Advertisement
Guest User

Untitled

a guest
Feb 20th, 2021
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 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. //Prompt user for how much cash they are using
  9.     float cash;
  10.     int remain;
  11.  
  12.     do
  13.     {
  14.         cash = get_float("Cash: \n");
  15.     }
  16.     while (cash < 0.01);
  17.  
  18.     int Cash = cash * 100;
  19.  
  20. //solve for how many quarters fit wholly into amount of cash, and calculate remainder of cash
  21.     int quarter;
  22.     {
  23.         quarter = round(Cash / 25);
  24.         remain = Cash % 25;
  25.     }
  26. // need to be able to pull out remainder
  27.  
  28. //dimes
  29.  
  30.     int dime, remain2;
  31.     {
  32.         dime = round(remain / 10);
  33.         remain2 = remain % 10;
  34.     }
  35. //nickels
  36.     int nickel, remain3;
  37.     {
  38.         nickel = round(remain2 / 5);
  39.         remain3 = remain2 % 5;
  40.     }
  41. //pennies
  42.     int penny, remain4;
  43.     {
  44.         penny = round(remain3 / 1);
  45.         remain4 = remain3 % 1;
  46.     }
  47. //tell the user how many coins will be needed
  48.  
  49.     int total = quarter + dime + nickel + penny;
  50.     printf("%i\n", total);
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement