1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
NemiM [27]
3 years ago
6

Write a program that reads an integer and determines and prints whether it's odd or even. [Hint: Use the remainder operator (%).

An even number is a multiple of two. Any multiple of 2 leaves a remainder of zero when divided by 2.]
Computers and Technology
1 answer:
Sloan [31]3 years ago
4 0
<h2>Explanation:</h2>

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;

<em>import java.util.Scanner;</em>

<em />

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

<em>Scanner input = new Scanner(System.in);</em>

(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 <em>number. </em>i.e

<em>int number = input.nextInt();</em>

<em></em>

(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 <em>number </em>is then checked using if and else blocks to check if it is even or not and can be written as follows;

<em>if(number % 2 == 0){</em>

<em>    System.out.println(number + " is even");</em>

<em>}else {</em>

<em>    System.out.println(number + " is odd");</em>

<em>}</em>

You might be interested in
Alicia would like to make important text in her spreadsheet stand out. Alicia should _____
Airida [17]
Probably bold the important text? Its hard without multiple choice
4 0
3 years ago
Read 2 more answers
What is the group scope for domain admins, domain controllers, and domain users default groups?
Igoryamba
The group of domain admins, domain controllers, and domain users default group is global. Thank you for posting your question here at brainly. I hope the answer will help you. Feel free to ask more questions.
4 0
3 years ago
EASY QUESTIONS! 10 POINTS AND BRAINLIEST FOR BEST ANSWER! PLEASE HELP ANSWER THIS only if you know BOTH ANSWERS!
Illusion [34]

Answer:

chain also why would some knock on their own dang door lol

Explanation:

it's easy indeed

8 0
4 years ago
Read 2 more answers
Which of the following is NOT an example of written communication?
Veronika [31]

Answer:A conversation between co-workers

Explanation:

4 0
3 years ago
It is very easy to change data into charts<br> what is a Microsoft Excel Microsoft Outlook or both​
Vadim26 [7]
It’s microsoft Excel
8 0
3 years ago
Other questions:
  • Alison retrieved data from a company database containing personal information on customers. When she looks at the SSN field, she
    14·1 answer
  • 1 what elements of composition are under your control in photoshop
    13·1 answer
  • A stop sign is an example of?
    11·2 answers
  • One of the main purposes of special effects is to accomplish shots that would be too expensive, too dangerous or just plain impo
    9·2 answers
  • What is media consumption ?
    12·2 answers
  • The user can set their own computer hostname and username. Which stage of the hardware lifecycle does this scenario belong to?
    6·1 answer
  • Susan teaches many individuals and business professionals how, why, and the benefits and challenges to using social media. Of th
    15·1 answer
  • Memory is the place of the computer where data and instructions are stored either permanently or temporarily. True or false.​
    11·1 answer
  • HELLLPPPPPP For each of the following discussion questions, write a response in complete sentences. Your response should be at l
    6·1 answer
  • Why would you choose a mobile device over a laptop? 1-2 sentences.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!