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
Lisa [10]
2 years ago
14

Write a static method middleValue that takes three int parameters, and returns a int . It should return the middle value of the

three parameters (sometimes called the median value). You may assume that all three parameters are different values (there are no duplicates).
Computers and Technology
1 answer:
anygoal [31]2 years ago
6 0

We use if-else structure to check the each possible scenario and return the median accordingly in the middleValue() method. The main is also provided so that you can test the method.

Comments are used to explain the each line.

You may see the output in the attachment.

public class Main

{

public static void main(String[] args) {

   

    //call the method for different scenarios

    System.out.println(middleValue(1, 2, 3));

    System.out.println(middleValue(1, 3, 2));

    System.out.println(middleValue(2, 1, 3));

    System.out.println(middleValue(2, 3, 1));

    System.out.println(middleValue(3, 1, 2));

    System.out.println(middleValue(3, 2, 1));

 

}

       //method that takes three int and returns an int

public static int middleValue(int n1, int n2, int n3) {

    //set the median as n1

    int median = n1;

   

    //check the situation where the n1 is the highest

    //if n2 is greater than n2 -> n1 > n2 > n3

    //if not -> n1 > n3 > n2

    if(n1 > n2 && n1 > n3){

        if(n2 > n3)

            median = n2;

        else

            median = n3;

    }

   

    //check the situation where the n2 is the highest

    //if n3 is greater than n1 -> n2 > n3 > n1

    //if not -> n2 > n1 > n3

    //note that we set the median as n1 by default, that is why there is no else part

    else if(n2 > n1 && n2 > n3){

        if(n3 > n1)

            median = n3;

    }

   

    //otherwise, n3 is the highest

    //if n2 is greater than n1 -> n3 > n2 > n1

    //if not -> n3 > n1 > n2

    //note that we set the median as n1 by default, that is why there is no else part

    else{

        if(n2 > n1)

            median = n2;

    }

   

    return median;

}

}

You may see another if-else question at:

brainly.com/question/13428325

You might be interested in
How can u refer to additional information while giving a presentation
yawa3891 [41]

Answer:

There are various ways: Handing out papers/fliers to people, or presenting slides.

7 0
3 years ago
Abrupt changes in road surface or the shape of the road may indicate
Zanzabum

Answer:

D. a potential hazard

Explanation:

Abrupt changes in road surface or the shape of the road may indicate a potential hazard.

5 0
3 years ago
Read 2 more answers
Hich chip contains the information necessary to start the computer system?
Sindrei [870]
The BIOS contains the information.
7 0
3 years ago
Create a presentation on “Pets” and customize your presentation in the following ways:
DaniilM [7]

Answer:

I used Microsoft PowerPoint 2010 to create my presentation. I created five slides on the topic of “Pets” and then customized the presentation.

Theme: I selected the Hardcover theme from the Design tab.

Slide Master: The Slide Master consists of all the design elements that I want for my slides. Therefore, I used the Slide Master option from the View tab. It gave me a view of all my slides in the form of thumbnails (on the left side) as Master Layouts. From the thumbnails list, I clicked on the top-most one (larger thumbnail) to edit it. On this master slide, I changed the background design, color scheme, and positioning of the placeholders.

Animation: There were certain slides for which I wanted to add animations. I individually selected those slides and clicked on the Animations Tab. I selected the Zoom animation style for the entry and exit of my text for particular slides.

Slide Layout: Within my presentation, I wanted a slide (slide number 5) to stand out from the rest. This slide would talk about the various pet stores in the vicinity. First, I used the Insert Layout option while being on the Slide Master view. Next, I used the Insert Placeholder option and selected Picture. Then, I had to drag the cursor to create a placeholder on the slide. I right clicked the thumbnail of this new slide and selected Rename Layout to change the name of this custom layout to “Pet Stores.”

Explanation:

This is the answer for Plato

5 0
3 years ago
Which item is used in Excel to identify the row of a particular cell? letter number type sheet
Alik [6]

It can be any letter or number as long as its validated.

7 0
3 years ago
Read 2 more answers
Other questions:
  • Part 1: Create an application that allows you to enter student data that consists of an ID number, first name, last name, and gr
    14·1 answer
  • How many different integers can be represented with a 4-digit number in base 13?
    8·1 answer
  • The idea that innovations in transportation and communication technologies has changed the way we think about distance and time
    9·1 answer
  • True or False: <br> The object reference can be used to polymorphically store any class in Java.
    13·1 answer
  • What can happen if you do not follow the directions when cooking or baking? (Give 4 examples in a sentence each)
    8·1 answer
  • Which of the following is an advantage of using variables?
    9·1 answer
  • In this project you will write a set of instructions (algorithm). The two grids below have colored boxes in different
    9·2 answers
  • A (n) ___ system can help a business alleviate the need for multiple information systems.
    13·1 answer
  • 1. Select two forms of case designed suitable for ATX power supply and
    13·1 answer
  • A(n) ___ is a set of CPUs which work in parallel in an attempt to simulate the way the human brain works, although in greatly si
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!