could someone please have a look at the following code and tell me what I'm doing wrong? I'm attaching the check50 checks. Thanks so much in advance
#include <cs50.h>
#include <stdio.h>
int main(void)
{
float change;
do
{
printf("O hai! How much change is owed?\n");
change = get_float();
}
while (change < 0 );
float cents = change *100; // create float cents
// initialise counter with 0
int counter = 0;
// loop as long as cents bigger than 0
while (cents > 0)
{
// substract 25 cents each time
while (cents >= 25)
{
cents = cents - 25;
counter++;
}
// substract 10 cents each time
while (cents >= 10)
{
cents = cents - 10;
counter++;
}
// substract 5 cents each time
while (cents >= 5 )
{
cents = cents - 5;
counter++;
}
// substract 1 cent each time
while (cents >= 1 )
{
cents = cents - 1;
counter++;
}
}
printf("%i\n", counter);
}
Checking..........
:) greedy exists
:) greedy compiles
:) input of 0.41 yields output of 4
:) input of 0.01 yields output of 1
:( input of 0.15 yields output of 2 did not find "2\n"
:) input of 1.6 yields output of 7
:) input of 23 yields output of 92
:( input of 4.2 yields output of 18 timed out while waiting for program to exit
:) rejects a negative input like -.1
:) rejects a non-numeric input of "foo"
:) rejects a non-numeric input of ""