After running check50 on my code for 'cash' in pset1 I'm getting the following errors:
:( input of 1.6 yields output of 7
did not find "7\n"
:( input of 23 yields output of 92
did not find "92\n"
:( input of 4.2 yields output of 18
timed out while waiting for program to exit
However when I run my program and use the same inputs it prompts me, as it should. So I want to submit my code, but I have to assume there's an error somewhere - would be great if someone could point it out.
My code is:
#include <stdio.h>
#include <cs50.h>
#include <math.h>
int main(void)
{
//Prompt user for an amount of change
float n;
do
{
n = get_float("How much change from a dollar?: \n");
}
while (n <= 0.00 || 1.00 <= n);
//Convert input to cents and assign to integer
int c = round(n * 100);
//Assign int values to cash
int quarter = 25;
int dime = 10;
int nickel = 5;
int cent = 1;
int count = 0;
//Check if a quarter (or more) is valid change
while (c >= quarter)
{
c = c - quarter;
count = count+1;
}
//Check if a dime (or more) is valid change
while (c >= dime)
{
c = c - dime;
count = count+1;
}
//Check if a nickel (or more) is valid change
while (c >= nickel)
{
c = c - nickel;
count = count+1;
}
//Check if a cent (or more) is valid change
while (c >= cent)
{
c = c - cent;
count = count+1;
}
//Print the count of coins
printf("Minimum number of coins for change is %d\n", count);
}
Thanks for any help!
Edit: don't know what's happened to the formatting... The includes are cs50, stdio and math