
write a program that reads an integer and check whether it is even. for example,
if your input is 25, the should be: is 25 an even number? false
if your input is 2000, the should be: is 2000 an even number?true

Hi Friend,
Try this:
import java.util.*;
class CheckNumber
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.print("Enter number: ");
int num=input.nextInt();
boolean check=false;
if(num%2==0){
check=true;
}
else{
check=false;
}
System.out.println("Is "+num+" an even number? "+check);
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.