Search:

Type: Posts; User: Norm

Search: Search took 0.20 seconds.

  1. Replies
    19
    Views
    2,351

    Re: problem with odd/even

    ?? No accounting for the grader.
  2. Replies
    19
    Views
    2,351

    Re: problem with odd/even

    Why are you using a while loop instead of a for loop?
    for loops are for when you use an index that starts at one value and changes that index until it has another value.
    While loops use...
  3. Replies
    19
    Views
    2,351

    Re: problem with odd/even

    Look at where the println statements are located. They are INSIDE the loop. They are executed every time the loop goes around. If you want them to execute at a different time, move them so they are...
  4. Replies
    19
    Views
    2,351

    Re: problem with odd/even

    Can you explain?
    What does "pull" mean?
    What is the final integer?

    Why are you using a while loop instead of a for loop?
  5. Replies
    19
    Views
    2,351

    Re: problem with odd/even

    Counter is a generic term I use for a variable (usually an int) that holds a count of something.

    I guess counter is the wrong term here. The code is supposed to total some numeric values not...
  6. Replies
    19
    Views
    2,351

    Re: problem with odd/even

    Use two counters, one for even, one for odd.
    Use an if statement to determine if the number is odd or even
    Add an odd number to the odd counter
    add an even number to the even counter.
  7. Replies
    19
    Views
    2,351

    Re: problem with odd/even

    Please post the code you are having problems with.
    If you can detect an even number then the else part must be odd. A number is one or the other.
  8. Replies
    19
    Views
    2,351

    Re: problem with odd/even

    That's strange, I'd expect you'd get this with the posted code:
    1
    0
    1
    0
    1
    0
    ...
    Add some more to the println so it also prints out the value of i as well as the value of i%2 so you can easily...
  9. Replies
    19
    Views
    2,351

    Re: problem with odd/even

    What have you tried? % is an arithmetic operator used the same as + or *
    Write a small test program that uses the % operator and print out the results to see what it does.
  10. Replies
    19
    Views
    2,351

    Re: problem with odd/even

    A couple of ways:
    Use the % operator with 2
    Test if the rightmost bit is a 1
Results 1 to 10 of 10