Search:

Type: Posts; User: pbrockway2

Search: Search took 0.10 seconds.

  1. [SOLVED] Re: Help with my Java program: Making change from an entered double.

    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.
  2. [SOLVED] Re: Help with my Java program: Making change from an entered double.

    Yes 0.04 strikes me as better than 0.05
  3. [SOLVED] Re: Help with my Java program: Making change from an entered double.

    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...
  4. [SOLVED] Re: Help with my Java program: Making change from an entered double.

    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...
  5. [SOLVED] Re: Help with my Java program: Making change from an entered double.

    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.
    ...
  6. [SOLVED] Re: Help with my Java program: Making change from an entered double.

    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...
  7. [SOLVED] Re: Help with my Java program: Making change from an entered double.

    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...
  8. [SOLVED] Re: Help with my Java program: Making change from an entered double.

    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...
Results 1 to 8 of 8