I have good number of coins for number over 1 with decimal (ex: 2.7, 5.1). And wrong number of coins only with numbers between 0 to 1 (0.99 or 0.41): always 0. plus the check50 says that it doesn't work with 4.2! Please could you hint me what could be my error because I have the integer already so I have no ideas. here is my code :
#include <cs50.h>
#include <stdio.h>
int main (void)
{
int conversion;
float change;
int amount = 0;
do
{
printf("O hai! How much change is owed ?");
change = get_float();
}
while (change < 0);
conversion = (int) change * 100;
while (conversion >= 25)
{
amount ++;
conversion = conversion - 25;
}
while (conversion >= 10)
{
amount ++;
conversion = conversion - 10;
}
while (conversion >= 5)
{
amount ++;
conversion = conversion - 5;
}
while (conversion >= 1)
{
amount ++;
conversion = conversion - 1;
}
printf("%d\n", amount);
}
thanks a lot.