<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 />