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
Discuss copyright issues as they relate to the Internet, including software piracy and digital rights management, and the Digita
LUCKY_DIMON [66]

To avoid privacy these copyright is been implemented. If copyright is not implemented software company such as Microsoft, Google cannot run the organization so that software has copyright and licenses and they protect from software privacy.

<u>Explanation:</u>

Since the world is digital world all software are available in internet for download and end user will not pay for software and use the software without purchasing from software development industries.

Even software are protected with key, hacker write the tool to brakes the key, so end user easily use these tools and generate the key and user it.

So that software company use Digital millennium copyright act, so that end user can arrested for missing the software’s.

5 0
3 years ago
Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
sdas [7]

Answer:

The modified program in Python is as follows:

import math

paint_colors = {'red': 35,'blue': 25,'green': 23}

wall_height = int(input('Enter wall height (feet):\n'))

wall_width = int(input('Enter wall width (feet):\n'))

area = wall_height*wall_width

print('Wall area:',area,'square feet')

paint_needed = area/350.0

print('Paint needed: {:.2f} gallons'.format(paint_needed))

print('Cans needed:',round(paint_needed),'can(s)')

color = input("Choose a color to paint the wall: ")

print("Cost of purchasing", color, "paint: $",paint_colors[color])

Explanation:

The italicized are given from the question [unchanged]

<em>import math</em>

<em> paint_colors = {'red': 35,'blue': 25,'green': 23} </em>

<em>wall_height = int(input('Enter wall height (feet):\n')) </em>

This gets input for width

wall_width = int(input('Enter wall width (feet):\n'))

Calculate the wall area

area = wall_height*wall_width

Print the calculated wall area

print('Wall area:',area,'square feet')

Calculate the amount of paint needed

paint_needed = area/350.0

Print the amount of paint needed to 2 decimal places

print('Paint needed: {:.2f} gallons'.format(paint_needed))

Print the amount of can needed to nearest integer

print('Cans needed:',round(paint_needed),'can(s)')

Prompt user for color of paint [here, we assume the user input is correct]

color = input("Choose a color to paint the wall: ")

Prints the corresponding amount for the color

print("Cost of purchasing", color, "paint: $",paint_colors[color])

3 0
2 years ago
State ONE (1) disadvantage of using computers to store and process<br> information.
NNADVOKAT [17]

Answer:

it can be hacked

Explanation:

there is always a chance for computer data to be hacked

3 0
2 years ago
What shoul i get, Airpods or a ps4 cooling fan ???
Fynjy0 [20]

Answer:

Airpods, there is ps5 coming out

Explanation:

3 0
2 years ago
Read 2 more answers
A database is used instead of a spreadsheet when
guajiro [1.7K]
            Both spreadsheets and databases, play a part in the daily
    operations of many businesses. While you do not necessarily need to choose between spreadsheets and databases, they are often suited to different types of tasks. Understanding the key differences between spreadsheets and databases is vital if you want to make the best use of either or both of them.
     Spreadsheets and databases share some characteristics, but they involve different technologies.
               Databases generally involve a higher level of technical processing.
-Rosie
4 0
3 years ago
Other questions:
  • What do you remember about the difference between Canadian and US dollar (which one is greater)? Also, explain which online tool
    6·1 answer
  • The incident results in huge losses of revenue as a result their mobile app service is withdrawn. Investigators discovered a vul
    5·1 answer
  • Choose all of the items that represent functions of the operating system kernel.
    15·2 answers
  • Problems and Exercises 16 through 43 are based on the entire ("big" version) Pine Valley Furniture Company database. Note: Depen
    13·1 answer
  • What happens when two computers have the same IP address?
    13·1 answer
  • If you want to insert a column into an existing table, what would you do?
    13·2 answers
  • A label control may be added to a form by double-clicking on the Label control icon in the ________ window.
    15·1 answer
  • Is orange named after the fruit or of the color?
    9·1 answer
  • If you do not clean your hardware on a regular basis, which of these is most likely to be a problem?
    11·1 answer
  • We love silky. she is very honest join this by using conjunction ​
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!