This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.

I apologize if this isnt the place to post questions in advance!

I have a program that im trying to build that takes a double value(such as 63.97) and tells you how much of each tender(10 dollar bills, 5, etc...) that it will take to match the original amount. When I go to run the program though, I get back how many of each bill it would take to hit the double value(such as 6 ten dollar bills, 6397 pennies, etc...), not sure if im explaining clearly, So far I have this

Now I think its either my Processing or my Output, any ideas or suggestions as to what might be the problem?

What you should do is to explain to yourself how to do the calculation with pencil and paper. Like this:

(1) I have $63.97. So how many $10 bills can I use? Well, I divide 6397 by 1000 and get 6.

(2) Okay, so now I have $63.97. So how many $5 bills can I use? Well, I divide 6397 by 5 and get 12.

... At this point you're going to stop me and explain what I did wrong. But that's what your code does. If you can fix my faulty calculation, then do the same fix to your code.

Chris Hathaway
Greenhorn

Joined: Feb 08, 2012
Posts: 16

posted

0

Your right thats what my code does at the moment.

What I need it to do is to update the remaining balance

like say I use $47.63, which was the teachers example, she got back

4 ten dollar bills
1 five dollar bills
2 one dollar bills
2 quarters
1 dimes
0 nickels
3 pennies

I dont think my code is updating the remaining balance, its still just dividing $63.97, thus giving me values like 6397 pennies