Determining if an integer is odd or even

Report a typo

Write a program that receives an integer as input, if the integer is even return 'even' else return 'odd'.

Sample Input 1:

2

Sample Output 1:

even

Sample Input 2:

3

Sample Output 2:

odd
Write a program in Java 25
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Read the input number
int number = scanner.nextInt();

// Write a one-line condition using ternary operator to check if the number is even or odd
// If the number is even, print "even"
// Otherwise, print "odd"
}
}

Create a free account to access the full topic