View Larger Image Java code to check Even or Odd number Copy to Clipboardimport java.util.Scanner; class CheckEvenOdd { public static void main(String args[]) { int num; System.out.println("Enter an Integer number:"); //The input provided by user is stored in num Scanner input = new Scanner(System.in); num = input.nextInt(); /* If number is divisible by 2 then it's an even number * else odd number*/ if ( num % 2 == 0 ) System.out.println("Entered number is even"); else System.out.println("Entered number is odd"); } }Output 1: Enter an Integer number: 78 Entered number is even Output 2: Enter an Integer number: 77 Entered number is odd By CodeBridge Editorial Team|2021-01-19T13:19:45-06:00January 19th, 2021|Java Core|0 Comments Share This Code, Choose Your Platform! FacebookTwitterPinterest Related Posts Java String replace() Java String replace() February 17th, 2019 | 0 Comments Java String replaceAll() Java String replaceAll() February 17th, 2019 | 0 Comments Java String split() Java String split() February 17th, 2019 | 0 Comments Object class in Java Object class in Java January 1st, 2019 | 0 Comments Object Cloning in Java Object Cloning in Java January 1st, 2019 | 1 Comment Leave A Comment Cancel replyComment Save my name, email, and website in this browser for the next time I comment. Δ
Leave A Comment