Computer Science, asked by mayanksharma63668, 2 months ago

write a program to find out whether the given even number is negative or not​

Answers

Answered by kamalrajatjoshi94
0

Answer:

import java.util.*;

public class NegativeEven

{

public static void main(String args[ ])

{

Scanner in=new Scanner(System.in);

int n;

System.out.println("Enter the number");

n=in.nextInt();

if(n>0&&n%2==0)

{

System.out.println("It is a negative even");

}

else if(n<0&&n%2==0)

{

System.out.println("The number is even but not negative i.e. it is a positive even");

}

else if(n>0&&n%2!=0)

{

System.out.println("The number is negative but not divisible by 2");

}

else if(n<0&&n%2!=0)

{

System.out.println("The number is neither negative nor an even number");

}

}

}

Similar questions