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
If the executives for Office Max LLC, a chain of office supply stores, developed the chain's objectives by asking buyers and sto
love history [14]

Answer:

It would be an example of bottom-up planning

Explanation:

Bottom-Up Planning is a method of planning that defines objectives and ways to achieve them through the bottom up. It relatively narrows goals that are initially set at the lower levels of the organizational hierarchy. First, relatively close targets at lower levels of the organizational hierarchy are set. They are then gradually integrated into the framework of global goals and global strategy at higher and higher levels. It is therefore a convergent approach.

With bottom-up planning, you give your project deeper focus because you have a larger number of employees involved in the project, each with their own area of expertise. Team members work side-by-side and have input during each stage of the process. Plans are developed at the lowest levels and are then passed on to each next higher level. It then reaches senior management for approval.

8 0
4 years ago
The graphical user interface (GUI) was pioneered in the mid-1970s by researchers at:
olasank [31]
IBM is the correct answer
5 0
3 years ago
Read 2 more answers
The process of providing only the essentials and hiding the details is known as _____. Group of answer choices algorithm abstrac
almond37 [142]
The answer is data structure
8 0
3 years ago
Which statement best describes the purpose of SmartArt graphics in PowerPoint presentations?
Alchen [17]

Answer:

They are an easy mechanism for combining text and graphics.

Explanation:

7 0
3 years ago
Read 2 more answers
.Write an if-else statement for the following:
bija089 [108]

Answer:

Solution part of the question:

if(userTickets>5)  //compare the value of userTickets with 5.

       awardPoints = 10; // assign the 10 value to the award point

       else

       awardPoints=userTickets;// assign the userticket value to the awardpoint.

Output:

For the input 4 the output is 4.

For the input 5 the output is 5.

For the input 6 the output is 10.

For the input 7 the output is 10.

Explanation:

All the other part of the program is given on the question so here only if-else statement is given on the answer part. Which is pasted at the place of "/* Your solution goes here */" and the user can get the right answer.

  • In the "if" statement the value of "userTickets" variable is get compared by 5 and if it is greater than 5 than variable "awardpoint" assigns the '10' value.
  • Otherwise, with the help of "else" statement "userticket" variables value (which is the input value for the program) assign to the "awardpoint" variable.
8 0
4 years ago
Read 2 more answers
Other questions:
  • What are three things to consider in programming design?
    14·1 answer
  • How it print media used? ​
    9·1 answer
  • Which hypervisor works on older pcs without hardware virtualization support?
    9·2 answers
  • Framing can create which of the following in a photograph? Mystery Saturation Aperture All of the above
    10·2 answers
  • Once I have entered text into a presentation, how do I modify the font style of the text? Select the text and use options availa
    9·2 answers
  • I love python. it be a good programming language...........................................
    11·1 answer
  • 3. Compilers and Assemblers translate each source file individually to generate object code files. Hence the object files need t
    13·1 answer
  • Question # 2 Multiple Select You wrote a program to compare the portion of drivers who were on the phone. Which statements are t
    15·1 answer
  • Which two characteristics of the matter change?
    14·1 answer
  • What connections do you see between variables and the Input-Output-Store-Process model of a computer?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!