Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cs50.h>
- #include <stdio.h>
- #include <math.h>
- int main(void)
- {
- //Prompt user for how much cash they are using
- float cash;
- int remain;
- do
- {
- cash = get_float("Cash: \n");
- }
- while (cash < 0.01);
- int Cash = cash * 100;
- //solve for how many quarters fit wholly into amount of cash, and calculate remainder of cash
- int quarter;
- {
- quarter = round(Cash / 25);
- remain = Cash % 25;
- }
- // need to be able to pull out remainder
- //dimes
- int dime, remain2;
- {
- dime = round(remain / 10);
- remain2 = remain % 10;
- }
- //nickels
- int nickel, remain3;
- {
- nickel = round(remain2 / 5);
- remain3 = remain2 % 5;
- }
- //pennies
- int penny, remain4;
- {
- penny = round(remain3 / 1);
- remain4 = remain3 % 1;
- }
- //tell the user how many coins will be needed
- int total = quarter + dime + nickel + penny;
- printf("%i\n", total);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement