I made a very simple program that distributes back change(quarters, dimes, nickels, and pennies) to the user. It distributes back the same amount, value, in change that the user inputs in cash. It was performing well until I input: 0.59 So, after tinkering with the program a little I was able to fix this issue. However, I still do not understand what exactly I did right to fix it...
int change_owed(float amount) {
int change, coins;
change = coins = 0;
change = (float)(amount * 1000000.0);
change /= 10000;
Any explanation would be great. Also, I apologize if this question has already been asked. Upon searching stackoverflow, I could not find a solution.