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
The difference between a want and a need is a want is not necessary for survival. Things necessary for survival are known as ___
Zarrin [17]
A.Needs since they are necessary and needed for survival 
8 0
3 years ago
When you record a macro, you can assign it to run from a button or from the _____.
arsen [322]
Depends on what software you use and how you set it up. But yea it’s possible
3 0
4 years ago
Read 2 more answers
ASAP 20 Points please hurry
inna [77]

Answer:

All you got to do is type System.out printIn("Study English) etc...

Explanation:

Look at the answer to see if it is right.

7 0
4 years ago
Situation 1: Mang Castor wanted to create a simple nutcracker Christmas tree
Papessa [141]

56856546856754578247

6 0
3 years ago
I just need some help working out this Java code! I can list the instructions below:
Ipatiy [6.2K]

Answer:

public class CountSpaces

{

   public static void main(String[] args)

   {

       String quote = "The concept of infinity is meaningless inside of an insane human mind.";

       int nrSpaces = calculateSpaces(quote);

       System.out.println("Nr spaces in your quote is " + nrSpaces);

   }

   

   public static int calculateSpaces(String inString)

   {

       int count = 0;

       

       for (int i = 0; i < inString.length(); i++) {

           if (inString.charAt(i) == ' ') {

               count++;

           }

       }

       return count;

   }

}

Explanation:

In this example there is only one class, and since all methods are static the true concept of the class is not even being used.

5 0
3 years ago
Other questions:
  • As referenced in this Canvas guide (Links to an external site.), Canvas is best viewed at a minimum of 800x600 pixels, which is
    5·1 answer
  • What is the difference between a router and a modem
    15·1 answer
  • There are many careers within the IT industry. _____ are responsible for organizing a company's data, making sure all the data i
    9·1 answer
  • 7.12 LAB: Contains the character
    12·2 answers
  • Manny has created more than one hundred bookmarks. When he looks at the menu, he has to scroll through a very long list of bookm
    15·1 answer
  • All objects in an object-oriented program are instantiated (created) from a ____.
    12·1 answer
  • Use pseudocode to specify a recursive algorithm to compute the nth value of the harmonic series, for some integer n.
    5·1 answer
  • The purpose of the align phase is to align your team with ______.
    9·1 answer
  • Which of these communication avenues is not regulated by the Federal Communications Commission (FCC)?
    12·1 answer
  • Data is stored on ________ using a laser to either melt the disc material or change the color of embedded dye.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!