You're welcome - I'm glad you've got it doing what you want.
Yes, x-=1 is rather like --x. --x, x--,++x, x++ exist in Java too.
The code would look like that in #7.
Type: Posts; User: pbrockway2
You're welcome - I'm glad you've got it doing what you want.
Yes, x-=1 is rather like --x. --x, x--,++x, x++ exist in Java too.
The code would look like that in #7.
Yes 0.04 strikes me as better than 0.05
First on the -= operator because I think it does simplify things a lot. x-=y is just a shorthand way of saying x=x-y or, in words "subtract y off x". But it's your code! Stay with what you're...
There is a ceil() method in the Math class. But, beware: it takes a double argument and returns a double value.
I think the approach I mentioned before (look for stray pennies and add 1 nickel if...
Well, giving change is mostly about arithmetic. I don't think there is some API shortcut. The problem you were given is basically meant to make you think about the fussy arithmetic details.
...
You subtract using - :)
The thing is to subtract each time you have figured out one of the values:
ten=(totalCents/1000);
totalCents -= ten * 1000; // this line subtracts the ten*1000...
This indicates a couple of things. First (obviously) you can't have 32.19... ten dollar bills. In fact the number of bills will be a whole number (0, 1, 2, ...) without a fraction. In your code it...
It would help very much if *you* said what was wrong.
Specifically, does that code compile? If not, and you can't understand the compiler's messages, post those messages and indicate which lines...