// EvenoddWithBitOperator.java Copyright (c) 2006 Kari Laitinen // http://www.naturalprogramming.com // 2006-02-23 File created. // 2006-02-23 Last modification. // A solution to Exercise 16-1. import java.util.* ; class EvenoddWithBitOperator { public static void main( String[] not_in_use ) { Scanner keyboard = new Scanner( System.in ) ; int integer_from_keyboard ; System.out.print( "\n This program can find out whether an integer" + "\n is even or odd. Please, enter an integer: " ) ; integer_from_keyboard = keyboard.nextInt( ) ; if ( ( integer_from_keyboard & 0x00000001 ) == 0 ) { System.out.print( "\n " + integer_from_keyboard + " is even.\n") ; } else { System.out.print( "\n " + integer_from_keyboard + " is odd. \n") ; } } }