# CS50 Pset 1 Cash cant convert to cents

I need help with converting to cents. I can get the code to compile, it doesn't accept negative numbers and passes a few other tests in CS50. However, I don't think the round function is working correctly.

When the code is run, I enter 1 and the output is 4. Does anyone have advice for me on how to convert to cents?

Here is the current logic I have for converting now. float change_in_cents;

``````do {
change_in_cents = get_float("Change owed:");
} while (change_in_cents < 0);
{int i = round(change_in_cents *100);
``````

I have been trying to debug this for too many hours, I even tried implementing a couple of ideas I found here but with no luck.

``````#include <stdio.h>
#include <cs50.h>
#include <math.h>

int main (void)
{
//define coins, quarter = 25, dime = 10, nickle = 5, penny = 1

const int QUARTER = 25;
const int DIME = 10;
const int NICKLE = 5;
const int PENNY = 1;

//prompt user for change until they give a non-negative value
//convert the change into cents to avoid dealing with floating point precision

float change_in_cents;
do {
change_in_cents = get_float("Change owed:");
} while (change_in_cents < 0);
{int i = round(change_in_cents *100);

//start with the largest coin value and see how many times it fits into the total change

int j = 0;
do {
// Count coins
if (i >= QUARTER) {
j++;
i -= QUARTER;
}
else if (i >= DIME) {
j++;
i -= DIME;
} else if (i >= NICKLE) {
j++;
i -= NICKLE;
} else if (i >= PENNY) {
j++;
i -= PENNY;
}
} while (i > 0);
printf("%d\n", j);
return 0;
}}
``````