I'm getting an error and I can't figure out the solution to this problem. I get an error at check cs50: "input of 0.41 yields output of 4; expected "4\n", not "You typed: 0.41..."
Here is my code:
#include <stdio.h>
#include <cs50.h>
#include <math.h>
int main (void)
{
float cents;
int coins, change;
do
{
cents = get_float ("Change: ");
} while (cents <= 0);
change = (int) roundf(cents * 100);
printf("You typed: %f\n", cents);
printf("You typed: %d\n", change);
for (coins = 0; change > 0; coins++)
{
if (change >= 25)
{
change -= 25;
}
else if (change < 25 && change >= 10)
{
change -= 10;
}
else if (change < 10 && change >= 5)
{
change -= 5;
}
else
{
change -= 1;
}
}
printf("Coins: %d\n", coins);
}
I searched for a solution to this problem but I could not find anything that worked. Thank you for your time!