# What am I doing wrong

Chris Hathaway

Greenhorn

Posts: 16

posted 4 years ago

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?

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?

posted 4 years ago

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.

(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

Posts: 16

posted 4 years ago

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

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

Chris Hathaway

Greenhorn

Posts: 16

George Black

Greenhorn

Posts: 3

posted 4 years ago

sorry .

first

.your code is not useful

dividing $47.63 is sharing $47.63

one man named tendollar get 4 so the money is Surplus $7.63

one man named fivedollar get 1 in $7.63 so the money is Surplus $2.63

````but what your method is the man named tendollar get 4 in $47.63 the man named fivedollar get 9 in $47.63 ```

hope could give you help

first

.your code is not useful

dividing $47.63 is sharing $47.63

one man named tendollar get 4 so the money is Surplus $7.63

one man named fivedollar get 1 in $7.63 so the money is Surplus $2.63

````but what your method is the man named tendollar get 4 in $47.63 the man named fivedollar get 9 in $47.63 ```

hope could give you help

It is sorta covered in the JavaRanch Style Guide. |