0

//conversion from user input

change *= 100;
change = roundf(change);
int actualchange = change;

//process

    {
        while (actualchange >= 25)
        actualchange -= 25;
        quarter++;
    }
    {   
        while (actualchange >= 10)
        actualchange -= 10;
        dime++;
    }
    {
        while (actualchange >= 5)
        actualchange -= 5;
        nickel++;
    }
    {
        while (actualchange >= 1)
        actualchange -= 1;
        penny++;
    }

//adding the variables to determine how many coins

int coins = quarter + dime + nickel + penny;

printf("You will get %d coins back!\n", coins);

I think I'm on the right track, but every time I put in a number, the output of coins is always 4. I'm not sure what I'm doing wrong. Any insight would be greatly appreciated.

2

You've misplaced the ' {} '

The proper position for braces should be

while (actualchange >= 25)
{
    actualchange -= 25;
    quarter++;
}

while (actualchange >= 10)
{
    actualchange -= 10;
    dime++;
}

while (actualchange >= 5)
{
    actualchange -= 5;
    nickel++;
}

while (actualchange >= 1)
{
    actualchange -= 1;
    penny++;
}
| improve this answer | |
  • I feel so stupid. Thanks so much!!! – Neggo Feb 16 '15 at 14:57
  • No problem. Everyone makes mistakes :) – Ibrahim Feb 16 '15 at 16:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .