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
Andrew [12]
3 years ago
8

Write a method, findMax(), that takes in two integers and returns the largest value. Ex: If the program input is: 4 2 the method

findMax() returns: 4 Note: Your program must define the method: public int findMax(int num1, int num2)
Computers and Technology
1 answer:
olya-2409 [2.1K]3 years ago
4 0
<h2>Answer:</h2><h2></h2>

public int findMax(int num1, int num2){

      if(num1 > num2){

           return num1;

      }

 

      else {

          return num2;

      }

}

<h2>Explanation:</h2>

<em></em>

The code has been written in Java and the following explains every part of the code.

<em>i. Start with the method header:</em>

<em>public int findMax(int num1, int num2)</em>

<em>ii. Followed by a pair of curly braces representing the block for the method.</em>

<em>public int findMax(int num1, int num2){</em>

<em>     </em>

<em>}</em>

<em />

<em>iii. Within the block, write the statements to find out which is greater between num1 and num2</em>

This is done with an if..else statement. To check if num1 is greater than num2, write the following within the block.

<em>if(num1 > num2){</em>

<em>    return num1;</em>

<em>}</em>

<em>else {</em>

<em>  return num2;</em>

<em>}</em>

<em />

The if block tests if num1 is greater than num2. If it is, then num1 will be returned.

The else block is executed only if num1 is not greater than num2. In this case, num2 will be returned since it is greater.

<em>iv. Put all together</em>

<em>public int findMax(int num1, int num2){</em>

<em>    if(num1 > num2){</em>

<em>        return num1;</em>

<em>    }</em>

<em>   else {</em>

<em>       return num2;</em>

<em>    }</em>

<em>}</em>

<em />

<em />

<em />

You might be interested in
Stacy plans to print her contacts and would like to choose an option that will print select information for each contact in a bu
Sergio039 [100]

Answer: card style

Explanation:

From the question, we are provided with the information that Stacy plans to print her contacts and the option that she would like to choose is an option that will print select information for each contact in a business card format.

Based on the above information that is given, the option that she should choose is the card style.

3 0
3 years ago
What does ADF means????
Anvisha [2.4K]

It means 'automatic document feeder'.

6 0
3 years ago
Read 2 more answers
In which of the following phases of filmmaking would a production team be focused on the
Anettt [7]
I think it’s pre production! Goodluck :)
7 0
3 years ago
Read 2 more answers
What is a traffic controller?what are its functions?
olchik [2.2K]

Answer:

A traffic controller is basically a system design to regulate traffic in a controlled manner with a set of traffic rules to follow so as to ensure public safety .

The main functions of a traffic light controller are listed below:

  • To direct  and regulate vehicular and pedestrian traffic
  • To ensure safety of construction workers, emergency response team and public in general in order to avoid accidents
  • These also uses CCTV and other monitoring system to manage flow of traffic and suggestion concerned with traffic congestion. These are provided by local or state authorities.
  • To ensure smooth traffic flow in order to save time and chaos.

4 0
3 years ago
How do IT security workers help business
Elodia [21]
They code and learn how to go in the inner and deeper parts of the computer
6 0
3 years ago
Other questions:
  • A machine is classified as a compound machine if it?
    8·2 answers
  • Which routine is configured to be called by another routine?
    10·1 answer
  • Data hiding, which means that critical data stored inside the object is protected from code outside the object, is accomplished
    14·2 answers
  • You are part of the team to implement new software at XYZ Inc. The employees at XYZ Inc. trust the results of the old software p
    15·1 answer
  • Explain why an IT department and a user support group may disagree about the responsibility for the development of end-user appl
    8·1 answer
  • You are a developer for a company that is planning on using the AWS RDS service. Your Database administrator spins up a new MySQ
    7·1 answer
  • What is the output of the following program?
    10·1 answer
  • You are given a 5-letter word (for example, abcde). Write a C-Program which outputs all possible unique 5 letter permutations of
    13·1 answer
  • Could someone please help?​
    10·1 answer
  • 1.1 give five (5) reasons why modeling is an important part of system analysis and design
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!