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
How many bit make a byte .​
Sauron [17]

Answer:

It is easy .8 bits.You have to note this

7 0
3 years ago
Read 2 more answers
Help me with this…… please
Brums [2.3K]

Answer:

2. The texture is being use to look sturdy

3. some repetition are being repeated for example the blocks

4. No it because of the words

5. The words at the bottom

It my opinion so it might not be correct

8 0
2 years ago
_______ tools enable people to connect and exchange ideas.
Serggg [28]

Answer:

B

Explanation:

I'm pretty sure it's B because I mean it makes the most sense

Hope I helped a little:)

Have a nice day!!

6 0
4 years ago
Read 2 more answers
What type of computer should you consider purchasing if you want a portable system that is good for students and on-the-go profe
Gemiola [76]

Answer:

laptop

Explanation:

,.....................

6 0
2 years ago
Of these two types of programs:a. I/O -bound b. CPU -bound which is more likely to have voluntary context switches, and which is
viktelen [127]

Answer:

For I/O-bound we require voluntary context switches.

For CPU-bound we require non-voluntary context switches.

Explanation:

A voluntary context switches occurs when process has given up control of the CPU because it requires a resource that is currently unavailable(such as blocking for I/O). It happen frequently in normal system operation. Voluntary context switching initiated with a call to the sleep() routine.

A non-voluntary context switches occurs when the CPU has taken away from a process, such as when it's time slice has expired or it has been preempted by a high-priority process. It is forced by direct invocation of the low-level context-switching mechanism embodied in the mi_switch() and setrunnable() routines.

7 0
4 years ago
Other questions:
  • Create a Flash Card class. Flash Cards have a Question and an Answer, each of which are Strings. Your class should include a con
    6·1 answer
  • If you're found to be at fault in _____, your driver license will be canceled within 90 days unless you complete a 12-hour Advan
    10·2 answers
  • What is a basic operation of computers
    13·1 answer
  • Your boss asks you to transmit a small file that includes sensitive personnel data to a server on the network. The server is run
    9·1 answer
  • The arrow next to all programs indicates
    13·1 answer
  • Describe a new career in computer science that may be created in the future. Include supporting evidence in your response that s
    13·1 answer
  • What is the meaning of the concept (atomically)
    11·1 answer
  • A customer has a computer for a home business, but wants to have another computer as a web server. What would be the best soluti
    11·2 answers
  • What is subscriber billing in Google Play and where does the money go?
    5·1 answer
  • Drag each tile to the correct box.
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!