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
Who was one of the founders of the location sharing site Foursquare​
Shalnov [3]

One of the founders of Foursquare is Dennis Crowley. The other is Naveen Selvadurai. I know you didn't ask for both but I wanted to give them to you just in case. I hope this helps! (:

7 0
2 years ago
Which of the following code correctly registers a handler with a button btOK?a. btOK.setOnAction(e -&gt; System.out.println("Han
Bad White [126]

Answer:

The correct answer is C:

btOK.setOnAction((ActionEvent e) -> System.out.println("Handle the event"));

Explanation:

The button produces an action once clicked. The setOnAction method indicates what will happen when the button is clicked. Action Event is a type of event that gets processed by EventHandler, which provides the action to be performed by clicking the button (printing out "Handle the event").

4 0
3 years ago
Do you watch markiplier?
ki77a [65]

Answer: Yes

Explanation: He is cool

5 0
3 years ago
Read 2 more answers
Assign numMatches with the number of elements in userValues that equal matchValue. userValues has NUM_VALS elements. Ex: If user
Sedbober [7]

Answer:

Replace /* Your solution goes here */ with:

cin>>matchValue;

numMatches = 0;

for (i = 0; i < userValues.size(); ++i) {

if(matchValue == userValues.at(i))

{

numMatches++;

}

}

Explanation:

This line gets input for matchValue

<em>cin>>matchValue; </em>

This line initializes numMatches to 0

<em>numMatches = 0; </em>

The following iteration checks for the number of matches (numMatches) of the matchValue

<em>for (i = 0; i < userValues.size(); ++i) { </em>

<em>if(matchValue == userValues.at(i)) </em>

<em>{ </em>

<em> numMatches++; </em>

<em>} </em>

<em>} </em>

<em>See Attachment for full source code</em>

Download cpp
3 0
2 years ago
What is the troubleshooting process?
sattari [20]
<span>It is a logical, systematic search for the source of a problem in order to solve it, and make the product or process operational again.Troubleshooting is needed to identify the symptoms. ...Troubleshooting is the process of isolating the specific cause or causes of the symptom.</span>
6 0
2 years ago
Other questions:
  • Technological _____ is the term used to describe the merging of several technologies into a single device.
    13·1 answer
  • It proceeds the statement causes execution of the current loop iteration to end and commence at the beginning of the next loop.
    10·1 answer
  • How do i build a supercomputer.?
    11·1 answer
  • Explain why professional software that is developed for a customer is not simply the programs that have been developed and deliv
    13·1 answer
  • What is Quantum Cryptography? How is it different from Public and Private-key transactions?
    6·1 answer
  • The physical parts of the computer are known as?
    14·1 answer
  • Write a single statement that assigns avg_sales with the average of num_sales1, num_sales2, and num_sales3.
    15·1 answer
  • In what way , if any, can your social media presence affect your chances of getting a job in social media?
    8·1 answer
  • 1. What are you going to do if someone ask for your personal information online?​
    12·2 answers
  • you want to upgrade your windows 10 professional computer to windows 11 professional. you begin by checking the hardware and dis
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!