![nails4life324](/avatars/34107.jpg)
nails4life324
22.04.2020 •
Computers and Technology
Match the certifications with the institutes that offer these certifications. Certified Ethical Hacker Certified Information Systems Security Professional Global Information Assurance Certification Certified Information Systems Auditor SANS ISACA (ISC)2 EC-Council
Solved
Show answers
More tips
- H Health and Medicine 5 Simple Steps to Quit Smoking for Good...
- C Computers and Internet How to Download Videos from YouTube? Simple Steps to Download Any Content...
- H Health and Medicine What is the Normal Blood Sugar Level in a Healthy Person?...
- S Style and Beauty How to Get Rid of Acne: Scientifically Proven Methods...
- L Leisure and Entertainment How to Choose the Perfect Gift for Men on February 23rd?...
- C Computers and Internet How to Delete Your Account on Odnoklassniki...
- H Health and Medicine 10 Simple and Effective Tips on How to Lose Weight in a Week...
- F Food and Cooking What s the Best Rice for Cooking Plov?...
- F Family and Home How to Get Rid of Your Neighbors?...
- S Society and Politics Secrets of NATO: Which Countries are Part of the Alliance?...
Answers on questions: Computers and Technology
- S Social Studies The formal methods for changing states constitutions are legislative proposals, ballot initiatives, referendums, and ....
- B Biology Timers at a swim meet used different clocks to time an event. Which recorded time is the most precise...
- B Biology There are two major reactions used by organisms for creating ENERGY and using ENERGY. One of them is Respiration. What is the overall reaction of this process?...
Ответ:
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");
}