What does the programmer what to find out from the following
Solution
Program:
import java.util.Scanner;
class Algorithm
{
public static void main(String args[])
{
int x,z=1; // Here we are initializing x,z are integer variables
Scanner in = new Scanner(System.in); // scanning input by the user
System.out.println(\"Please enter the value of x : \");
x = in.nextInt(); // reading input from the user
if(2*(x/2)==x) // checking the condition if total value is equals to entered value of x
{
System.out.println(\"Value is EVEN:= \"+z);
}
else if(2*(x/2)<x) // checking the condition if total value is less than to the entered value of x
{
System.out.println(\"Value is ODD:= \"+z);
}
else if(2*(x/2)>x) // checking the condition if total value is greater than to the entered value of x
{
System.out.println(\"Value is ODD:= \"+z);
}
}
}
Output:
Please enter the value of x : 6
value is EVEN :=1
