Java Online Compiler
Example: Java Program to Check Even or Odd Number using If-else Statement
C
C++
C#
Java
Python
PHP
Main.java
STDIN
Run
// Java Program to Check Even or Odd Number using If-else Statement import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int x; System.out.println ("Enter an integer number to check:\n"); x = in.nextInt(); if (x % 2 == 0) { System.out.println ("The input number is even.\n"); } else { System.out.println ("The input number is odd.\n"); } } }
44
Output
Clear
ADVERTISEMENTS