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.
Dear User, We are grateful for your interest in the Kodingwindow Android app. We intend to soon make it available on the Google Play Store. Currently, Android versions 10 and up require manual apk installations. Would you like to get the app?