Java program to check the given number is even or odd
KW.java
importjava.util.Scanner;classKW{publicstaticvoidmain(Stringargs[]){intx;Scannersc=newScanner(System.in);System.out.println("———————————————————————————————————————————");System.out.println("Program for even-odd test of a given number");System.out.println("———————————————————————————————————————————");System.out.print("Enter a number ");x=sc.nextInt();//if((x>>1)<<1==x)if(x%2==0){System.out.println("\nEntered number is EVEN");}else{System.out.println("\nEntered number is ODD");}System.out.println("———————————————————————————————————————————");}}
Output
kodingwindow@kw:~$ javac KW.java kodingwindow@kw:~$ java KW
———————————————————————————————————————————
Program for even-odd test of a given number
———————————————————————————————————————————
Enter a number -5005
Entered number is ODD
———————————————————————————————————————————
kodingwindow@kw:~$
Dear User, Thank you for visitng KodingWindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.