Java Online Compiler
Example: Java Program to Check Whether a Number is Even or Odd using Function
C
C++
C#
Java
Python
PHP
Main.java
STDIN
Run
// Java Program to Check Whether a Number is Even or Odd using Function 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(); IsEvenNumber(x); } public static void IsEvenNumber(int x) { if (x % 2 == 0) { System.out.println ("The input number is even."); } else { System.out.println ("The input number is odd."); } } }
45
Output
Clear
ADVERTISEMENTS