0
#include <cs50.h>
#include <stdio.h>
#include <math.h>

int main(void)
{
    float change;
    int coins = 0;
    do
    {
        change = get_float("Change owed: ");
    }
    while (change < 0);
    int cents = round (change * 100);
    if (cents >=25)
    {
        coins++;
        cents-=25;
    }
    else if (cents >=10)
    {
        coins++;
        cents-=10;
    }
    else if (cents >=5)
    {
        coins++;
        cents-=5;
    }
    else if (cents >=1)
    {
        coins++;
        cents-=1;
    }
    else (cents = 0);
    {
        printf("You can use %i\n", coins);
    }
}

It keeps giving 1 as answer! Don't knnow what I should change or where the problem is.

2
  • Remember when you are using if statements it will only execute once unless it is in a loop, my advice would be to study about if statements and loops, hint for this problem when I solved this I didn't use any if else statements – Ojou Nii Apr 4 '20 at 15:44
  • It worked! Thank you! – hello.21 Apr 5 '20 at 18:28

You must log in to answer this question.

Browse other questions tagged .