Source code
//define a class called IfElseExample
public class IfElseExample {
//define the main method
public static void main(String[] args) {
/*
define a variable named number and initialize it to 13
*/
int number=13;
/*
check the number is divisible by two (even)
if it is even display "even number" on the screen
*/
if(number%2==0){
System.out.println("even number");
}
/*
if the number is not divisible by two is even display "odd number" on the screen
*/
else{
System.out.println("odd number");
}
}
}
Output
Comments
Leave a comment