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
Given this method comment, fill in the blank in the method implementation. /* Deposits money into the bank account amount: the a
DIA [1.3K]

Answer:

"void" is the correct answer for the given question.

Explanation:

In the function body the value of balance variable is not return that means we use void return type .The void return type is used when the function does not return any value .

If the function are  int return type that means it return "integer value ".

if the function are  double return type that means it return the "double value" .

The complete implementation of this method is

public void deposit(double amount) // function definition  

{

balance = balance + amount; // statement

}

3 0
3 years ago
Assume that source elements of length k are mapped in some uniform fashion into a target elements of length p. If each digit can
lukranit [14]

Answer And explanation

a)

r^k has 1/r^k probability guess the correct source

b)

Each element in r^p  is mapped by r^k / r^p . There are r^k^-^p  So there are  r^k^-^p -1 elements.

number of target elements = r^k^-^p

number of source elements = r^k^-^p -1

probability = r^k^-^p -1 /r^k

c) Probability of the correct target element

1/r^p

6 0
3 years ago
The Fibonacci numbers are a sequence of integers in which the first two elements are 1, and each following element is the sum of
ioda

Answer:

// program in java to print 12 fibonacci terms

// package

import java.util.*;

// class definition

class Main

{

   // main method of the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

     

      // variables

      int no_of_term=12, f_term = 1, s_term = 1, n_term = 0;

      System.out.print("First 12 term of Fibonacci Series:");

      // print 12 terms of the Series

       for (int x = 1; x<= no_of_term; x++)

           {

       // Prints the first two terms.

            if(x <=2 )

            System.out.print(1+" ");

            else

            {

               // find the next term

                n_term = f_term + s_term;

                // update the last two terms

                f_term = s_term;

                s_term = n_term;

                // print the next term

              System.out.print(n_term+" ");

            }

           }

     

     

   }catch(Exception ex){

       return;}

}

}

Explanation:

Declare and initialize no_of_term=12,f_term=1,s_term=1 and n_term=0.Run a loop  for 12 times, for first term print 1 and then next term will be calculated as  sum of previous two term of Series.Then update previous two term.This will  continue for 12 time and print the terms of Fibonacci Series.

Output:

First 12 term of Fibonacci Series:1 1 2 3 5 8 13 21 34 55 89 144

4 0
3 years ago
Technician A says that the TP sensor signal voltage should be about 0.5 volt at idle and increase to about 2.5 volts at wide-ope
swat32

Answer:

Both are right.

Explanation:

4 0
3 years ago
When a windows computer starts, it initiates the stateless address autoconfiguration process, during which it assigns each inter
stiks02 [169]
1) <span>The IPv6 implementation on the system construct a link-local address for
     each interface by using the fe80::/64 network address
2) </span><span> Using IPv6 Neighbor Discovery protocol, the system check if the
     address is a duplicate 
</span>3) <span>Knowing the link-local address is unique, it configures the interface to use
    that address
4) </span><span>The system uses the Neighbor Discovery protocol to transmit Router
     Solicitation messages to the all routers multicast address 
5) </span><span>The router on the link uses the ND protocol to relay Router
     Advertisement messages to the system 
6) </span><span>By using the information it receives from the router, the system produce
    a routable address and configures the interface to use it </span>
5 0
3 years ago
Other questions:
  • Write program statements to determine the fewest number of bills needed to represent a total dollar amount.
    11·1 answer
  • If you were looking for a record in a very large database and you knew the ID number, which of the following commands would be t
    10·1 answer
  • Which of the following is the process of transferring data in a continuous and even flow, which allows users to access and use a
    12·1 answer
  • Application software definition word excel powerpoint microsoft
    13·1 answer
  • What is an internt?​
    10·1 answer
  • What is the by stander effect
    9·1 answer
  • 16. Select the correct answer.
    13·1 answer
  • In a relational database, the three basic operations used to develop useful sets of data are:_________.
    14·1 answer
  • What is the best Genshin impact ship? My favorite is Xiao x Lumine. Put yours bellow.
    13·2 answers
  • Davids family took him to a hospital as he was suffering from a sericous ailment
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!