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
Fantom [35]
3 years ago
10

in java how do i Write a method named isEven that accepts an int argument. The method should return true if the argument is even

, or false otherwise. Also write a program to test your method.
Computers and Technology
1 answer:
Veseljchak [2.6K]3 years ago
3 0
<h2>Answer:</h2><h2>============================================</h2>

//Class header definition

public class TestEven {

   

   //Method main to test the method isEven

   public static void main(String args[ ] ) {

       

       //Test the method isEven using numbers 5 and 6 as arguments

       System.out.println(isEven(5));

       System.out.println(isEven(6));

     

   }

   

   //Method isEven

   //Method has a return type of boolean since it returns true or false.

   //Method has an int parameter

   public static boolean isEven(int number){

       //A number is even if its modulus with 2 gives zero

      if (number % 2 == 0){

           return true;

       }

       

       //Otherwise, the number is odd

       return false;

   }

}

====================================================

<h2>Sample Output:</h2>

=========================================================

false

true

==========================================================

<h2>Explanation:</h2>

The above code has been written in Java. It contains comments explaining every part of the code. Please go through the comments in the code.

A sample output has also been provided. You can save the code as TestEven.java and run it on your machine.

You might be interested in
In 3-4 sentences, write a note to a friend describ
sladkih [1.3K]

you can copy and paste your text.

7 0
3 years ago
Read 2 more answers
Please Help Me!!! 40 Points!! Match the correct definition to each term
fgiga [73]

Answer:

is there anymore to this problem because I would like to help you out more mate.

6 0
3 years ago
La computadora es un medio de comunicacion moderno?
kolbaska11 [484]
Moderno = mordern, if It does than yes!
3 0
3 years ago
Remember not to use tools that are ________ in any way.
kupik [55]
Remember not to use tools that are rusty and damaged in any way.
3 0
3 years ago
You are designing a Webpage for your company's site that reaches an international audience. What should you do to solve the prob
Helga [31]
It is b cause of its answer
8 0
3 years ago
Other questions:
  • You are attempting to open a file containing a list of integer numbers, each on a separate line, and read them into Python as in
    6·1 answer
  • The extension name of a java bytecode file is ________.
    8·1 answer
  • Mass Media does not play a large role in American society. Please select the best answer from the choices provided
    13·2 answers
  • Write a program that reads in two integers typed on the keyboard and outputs their sum, difference, and product.
    12·1 answer
  • Write a program that calculates the balance of a savings account at the end of a period of time. It should ask the user for the
    14·1 answer
  • Which vulnerability can occur if a programmer does not properly validate user input and allows an attacker to include unintended
    13·1 answer
  • I need help building a computer what are some good parts?
    9·1 answer
  • Why header files are needed in every c program ?expalin​
    14·1 answer
  • On the worksheet, make cell a1 the active cell and then simultaneously replace all occurrences of the value 0. 05 with the value
    12·1 answer
  • Which instructions are used to change the sequence of instruction execution? group of answer choices data movement operate contr
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!