Search:

Type: Posts; User: Norm

Search: Search took 0.11 seconds.

  1. Re: Having trouble with switch statements for a school work

    Where does the program get its input from? Are they entered by a user?
    The code I posted shows a way to determine if a number is even or odd.
    Here is another example:

    int val = 4; //...
  2. Re: Having trouble with switch statements for a school work

    Test the lower order bit of an int to determine if it is odd or even. If the bit is 1, it is odd. Use the AND operator (&) with a 1.
    For example:

    System.out.println("odd " + (3 & 1) + ",...
Results 1 to 2 of 2