Introduction: Java Code/Program - Check/Test Number Even/Odd

Short Java program that asks the user to type in a number, uses the Modulus operator to find a remainder to test to see if it is even or odd.

Step 1: Jave Code Below and Attached

import java.util.Scanner;

class MattROddEvenTest


   public static void main(String args[])   {

       Scanner keyboardInput = new Scanner(;

       int numberEntered;

       int modulusResult;

       System.out.println("Please enter an integer number to determine if it is even or odd: ");

       numberEntered = keyboardInput.nextInt();

       // Divide by 2 using modulus

       modulusResult = numberEntered % 2;

       System.out.print("The modulus result is: ");


       // Now test to see if the remainder is "Zero"

       // If it is zero, then it is an even number

       if (modulusResult == 0) {

           System.out.println("The number entered was even.");

       } // end if loop

       else {

           System.out.println("The number entered was odd.");

       } // end else loop

   } // end public static void main

} // end class MattREvenOddTest