I'm working on the Cash program in Week 2 and I think I have it all finished up the only problem is when I run check50 I get everything right except for .41 instead of returning 4 coins it gives an answer of 3 coins and I just can't figure out why. It returns the correct value for every other answer but not this one and I'm stumped. I appreciate any help or advice. Here's my code:
#include <cs50.h>
#include <stdio.h>
#include <math.h>
int main(void)
{
float dollar;
do
{
dollar = get_float("Change: $");
}
while (dollar <= 0);
int cents = dollar * 100;
int coins = 0;
while (cents >= 25)
{
cents = cents - 25;
coins++;
}
while (cents >= 10)
{
cents = cents - 10;
coins++;
}
while (cents >= 5)
{
cents = cents - 10;
coins++;
}
while (cents > 0)
{
cents = cents - 1;
coins++;
}
printf("You will need at least %i coins\n", coins);
}