Write a complete Java program that prompts the user for an i

Write a complete Java program that prompts the user for an integer, reads it into an integer variable named value using a Scanner. The program should then print out either \"EVEN\" or \"ODD\" depending upon whether or not the value is an even or odd number. Be sure to include all necessary statements in the program.   Be sure that your program works correctly. .

Solution

EvenOdd.java


import java.util.Scanner;//key board inputting


public class EvenOdd {//main class
    public static void main(String args[])
    {//main method
        int num;
        Scanner sc=new Scanner(System.in);
        try{//exception hangling
        System.out.println(\"Enter any number\");
        num=sc.nextInt();//key board inputting
        if(num%2==0)//logic for even odd
            System.out.println(\"EVEN\");
        else
            System.out.println(\"ODD\");
    }catch(Exception e)
    {
        System.out.println(\"Please enter Integers only\");
    }
    }
  
}  
  
  


output

Enter any number
123
ODD

Enter any number
reer
Please enter Integers only

Write a complete Java program that prompts the user for an integer, reads it into an integer variable named value using a Scanner. The program should then print

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site