Check if a number is even

Check if a number is even

Using if-else statements, check if the number entered is even. If a number is even, it should return “Even”. Otherwise, return “Not Even”. Remember, a number is even if when divided by 2 returns 0. (HINT: Use modulo operator).

Example 1:


input data:
5
output:
Not Even

Example 2:


input data:
18
output:
Even
View Code Template
View Java Solution

Seda
Seda Kunda is a web designer and developer with a degree in Computer Science and a great passion for code. Besides code, she enjoys pepperoni pizza, watching the bachelor and sleeping in on Saturdays.
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

2 thoughts on “Check if a number is even

  1. public void calEven(int ev){

    if(ev%2 == 0){
    System.out.printf(“Even”);
    }else{
    System.out.printf(“Sorry”);
    }

Comments are closed.