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
Which two components in a system might make a loud whining noise when there is a problem? Why?
umka21 [38]

The power supply and the Hard drive are the two components that makes loud whining noise when a problem is detected.

<u>Explanation:</u>

  • Computers can undergo what's called “coil whine,” which is a high-pitched noise that originates from the computer.
  • coil whine is an unacceptable noise emitted by an electronic component vibrating as power runs through an electrical cable.
  • It's easy to infer that the noise is an indication of influential computer malfunctioning or that something is cut, disconnected, or about to collapse.
  • It is normally caused by an electrical current passing through a power-regulating component like a transformer or inductor, inducing its electrical wiring to vibrate at a shifting frequency.
  • Luckily, coil whine is normal behavior.
5 0
3 years ago
Which of the following data structures can erase from its beginning or its end in O(1) time?
jekas [21]

Where all "the following" i can help you but you said which of the folllowing and ther no picture or anything?

3 0
3 years ago
Which shortcut keys can be used to duplicate a slide?
Leya [2.2K]

Answer:

Ctrl + D used to duplicate a slide

8 0
3 years ago
I need help ASAP Please! :)
amid [387]
Your parents,your school,google,your social media accounts
3 0
3 years ago
It's best to use assertive speech when you<br> I want to show respect. *<br> True<br> False
mestny [16]

Answer:

True

Explanation:

Hope this helps :)

6 0
3 years ago
Read 2 more answers
Other questions:
  • A company decides to create static design diagrams for an upcoming project. Which statement correctly describes the attribute of
    6·1 answer
  • Drag each storage device to its category.
    7·1 answer
  • 5. The hazardous component in most antifreeze is _____, which is extremely toxic to humans and animals. A) Calcium Carbonate B)
    13·2 answers
  • Match each vocabulary word to its definition.
    11·2 answers
  • Write a method reverse( ) for OurLinkedList class. The method should return a new OurLinkedList object that is the reverse of th
    8·1 answer
  • The continue statement _________.
    11·1 answer
  • You have a web application hosted in AWS cloud where the application logs are sent to Amazon CloudWatch. Lately, the web applica
    7·1 answer
  • What is the purpose of file extensions? A. They execute the mail merge function, B. They tell the operating system what kind of
    15·2 answers
  • All the network nodes are connected to each other
    8·1 answer
  • EMERGENCY- I am giving 55 points for this, please help. WITH working out
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!