Free Puzzle Questions with Answer using Java, C#, JavaScript and PHP

Java Quiz - Check Prime Number

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package check.prime.number;

import java.util.Scanner;

/**
 *
 * @author Bereket
 */
public class CheckPrimeNumber {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        System.out.print("Enter any number: ");
        int input = scanner.nextInt();
        
        int temp;
        boolean isPrime = true;
        
        for(int i=2; i <= input/2; i++){
            temp = input % i;
            if(temp == 0){
                isPrime = false;
                break;
            }
        }
        
        if(isPrime == true){
            System.out.println("The given number is PRIME NUMBER");
        }
        else{
            System.out.println("The given number is NOT PRIME NUMBER");
        }
    }
    
}