The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

change finder

hey guys below is my code for a change finder the code takes in a sales total and the amount payed and gives a change value and the amount of coins without using nickles. i cant seem to figure out however why the code is one cent short on
Given $36.0 for a purchase of $32.27 we need
3 dollars 2 quarters 2 dimes 2 cents

it should be 3 cents not 2 it is right on my other tests however.
here is my code

Re: change finder

The code is not properly formatted making it hard to read and understand. All statements should not start in the first column. Nested statements should be indented 3-4 spaces.

Print out the value of change to see what the problem is. There is a problem working with doubles with integer like values. There is a web page somewhere that explains the rounding/precision problems with using doubles for currency computations.
I got this from google:http://docs.oracle.com/cd/E19957-01/..._goldberg.html