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]
2 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]2 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
Your browser has blocked your from your crucial secure intranet sites. What could be the problem?.
Alenkinab [10]

A browser is a program that allows and provides the user access to information and web pages on the internet. It blocks someone when their SSL certificate status has been voided.

<h3>What is an SSL certificate?</h3>

An SSL (Secure Sockets Layer) certificate is a digital code and certificate present on the web that authenticates and provides security for communication. It is a security protocol that allows encrypted transmission.

The firewall supervisor sets the rule to block or allow the users to connect to Crucial Secure Intranet Sites based on their SSL certificates. SSL certificate if gets revoked then does not allow users to reach the site and declares it to be a potential risk.

Therefore, the browser is not reachable when the SSL certificate gets expired.

Learn more about SSL certificates here:

brainly.com/question/24276018

#SPJ1

3 0
2 years ago
How can people efficiently and effectively influence lots of people throughout the world
tatuchka [14]

Answer:

The word efficient denotes the ability to achieve a good goal toward a person, and effectiveness denotes reliable production or achievement.

Explanation:

Many people around the world can set efficient goals, that is, to influence or encourage other people to make good projects or changes in their lives, by example or simply teach them with patience and altruism.

In this way effectiveness will be seen, that is, the product or the achievement precisely when we observe how people undertake new projects in their lives

3 0
3 years ago
When the amount of storage data is big, and we need the searching and insertion must be very fast, which kind of data structure
dangina [55]

Answer:

b. Binary tree

Explanation:

The time complexity of a binary tree is O(log n). As it scales up in size (n), the time taken is only log n. This is because it makes use of divide and conquer to split up the data which makes searching and inserting very simple. However, this only holds if the data is already sorted.

4 0
2 years ago
Which platform is the best? (X-box, PC, Playstation, Nintendo Switch, Wii)
Akimi4 [234]
PlayStation for sure
3 0
3 years ago
The basic building blocks of java is known as<br><br><br><br>Reply fast! plzzzzzzzzzzz!!!
Nadya [2.5K]

Answer:

A class is the basic building block in Java.

8 0
2 years ago
Other questions:
  • You disassemble and reassemble a desktop computer. when you first turn it on, you see no lights and hear no sounds. nothing appe
    11·2 answers
  • how can you create fades with the smart tool? How can you specify the types of fade curves that are used with the smart tool?
    13·1 answer
  • What was the first Apple computer, and who was it designed by?
    7·2 answers
  • What does the /var directory contain?
    7·1 answer
  • The _____ provides a basis for creating the project schedule and performing earned value management for measuring and forecastin
    6·1 answer
  • 4) Wilkes continues to discuss the concept of time and how it relates to the type of photography he does. Why do you feel that t
    12·1 answer
  • Krya needs help deciding which colors she should use on her web page. What can she use to help her decide.
    11·1 answer
  • Pie charts are best used for
    5·1 answer
  • How did the tropica cyclone impact the environment​
    14·1 answer
  • joe is in the planning stages to make sure that an upcoming company promotion during a major sporting event will not overwhelm h
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!