I am unsure why it is not giving me the output that I want because when I look at this to me it should work. If I posted too much code then tell me and I will take it down but I tried to limit it so it wouldn't go against the academic honesty. I have the code that prompts the user for input which I have saved in variable change. If you would like to see all of my code then let me know. I am new to coding but this pset1 has taken WAY too long for me to complete I struggled with mario too. So I don't know if it's just the way I am going about attacking the problem or what but any help would be greatly appreciated! Thanks in advanced.
EDIT so I have edited some of my code and I am displaying all of my code BUT it's not working still. I think that the reason has something to do with when I round? Or maybe the fact that I am using Do While loops? The problem is when I input .01 it gives out 4 and if I do 4.2 it gives out 7.
#include <stdio.h>
#include <cs50.h>
#include <math.h>
int main(void)
{
float change;
do
{
printf("How much change is owed?\n");
change = GetFloat();
}
while(change <= 0);
change = roundf(change * .20);
float Q = .25;
int count = 0;
do
{
change -= Q;
count++;
}
while(change >= Q);
float D = .10;
do
{
change -= D;
count++;
}
while(change >= D);
float N = .5;
do
{
change -= N;
count++;
}
while(change >= N);
float P = .01;
do
{
change -= P;
count++;
}
while(change >= P);
printf("%d\n", count);
}