I have a change making program I'm writing that asks a user for a monetary amount, then it breaks down that amount into smaller values.
So it uses the Scanner class to elicit a double like 99.99. I want it to use 10.00 as it's largest amount and give 9 x 10.00, 1 x 5.00, 4 x 1.00, 3x .25, etc.
So far I have the following:
Where I'm tripping up is in the division. I'm getting back the wrong amount back (9.998999999999999). I want to divide by 10.00 and get the remainder in a separate variable to then be divided by 5.00, etc.
I don't really get how the whole widening conversion thing works, and I _really_ don't get how to use the % operator in this context to divide by 10.00 and get the remainder of 9.99 back into some type of useful variable that I can then divide?
The book I'm reading explains it, but I seem to be too thick to get it to work on my own.
Thanks for any help.
Dave