Respuesta :

Explanation:

The source code, written in Java, and a sample output have been attached to this response. It contains comments explaining certain parts of the code.

A few things to note are;

(i) The Scanner class is imported to allow user's interact with the program. This is done by writing the import statement at the top of the code as follows;

import java.util.Scanner;

(ii) An object of the Scanner class is created to receive inputs from the user. The object is called input and created as follows;

Scanner input = new Scanner(System.in);

(iii) Since the user is expected to enter an integer, the nextInt() method of the Scanner object is used to receive the integer and this is saved in a variable called number. i.e

int number = input.nextInt();

(iv) A number x, is even if its remainder when divided by 2 is 0. i.e

if x % 2 = 0, then x is even. Otherwise it is odd.

The user's input received and saved in a variable called number is then checked using if and else blocks to check if it is even or not and can be written as follows;

if(number % 2 == 0){

   System.out.println(number + " is even");

}else {

   System.out.println(number + " is odd");

}

Ver imagen stigawithfun
Ver imagen stigawithfun