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]
3 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]3 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
. What physical characteristic does a retinal scan biometric device measure?
elena-s [515]

Answer: D)The pattern of blood vessels at the back of the eye.

Explanation: The retinal scan is the techniques which is used in the bio-metric mechanism.The scanning of the retina's blood vessel pattern is capture by the scanner is the unique technique which is used for bio-metric purpose.

Blood vessel pattern is capture because it is present in unique form for every person and will help in distinguishing a person from another person while scanning.

Other options are incorrect because light reflection or reaching near retina and light pattern are not the unique way for identification while scanning a person.Thus the correct option is option(D).

4 0
3 years ago
The ____ section of the project plan should describe the major project functions and activities and identify those individuals w
harkovskaia [24]

Answer:

Option(c) is the correct answer to the given question .

Explanation:

The Project responsibilities section is responsible of the planning of project.

Following are the Roles of the Project Responsibilities

  • To check the objective of the project goals.
  • Works with customers and  to define and meet client needs and the overall objective .
  • Cost estimation and expenditure production of the project
  • Ensure the fulfillment of the client .Analysis and enterprise risk management. and Tracking the progress of project.

All the others options are not responsible of the planning of project that's why Option(c) is the correct answer .

7 0
3 years ago
Describe how a black and white image could be represented in binary
SIZIF [17.4K]

Answer:

Each pixel in an image is made up of binary numbers. If we say that 1 is black (or on) and 0 is white (or off), then a simple black and white picture can be created using binary. To create the picture, a grid can be set out and the squares coloured (1 – black and 0 – white).

5 0
3 years ago
Read 2 more answers
i need a moderator or someone to answer this :/ why do i keep getting notifications that i have a new chat or a new answer/comme
Lyrx [107]

Answer:

It happens to me as well. Maybe check emails?  It could also be a bug.

Explanation:

4 0
3 years ago
Read 2 more answers
What are 6 external parts or perpherals of a computer system and identify output from input devices.
n200080 [17]
40. External Peripherals of a Computer systems are the following: -> Keyboard – this is an input device -> Mouse – This is an input device also -> Printer – this is an output device -> Flashdrive – This is a storage device -> Monitor – this is an output device -> external hard drive – this is a storage device Output device are those devices that communicate the results of the data processing to the user Input device are those device that communicate the results of the data processing to the computer system Storage device are those device that stores data.
4 0
3 years ago
Other questions:
  • 1- How should an operating system support communication between applications? explain your reasoning?
    10·1 answer
  • 9.1.3: Printing vector elements with a for loop. Write a for loop to print all NUM_VALS elements of vector courseGrades, followi
    5·1 answer
  • What device provides ports to allow a laptop to easily connect to a full-sized monitor, keyboard, ac power adapter, and other pe
    11·1 answer
  • Calvin needs to design a simple yet professional interface for his users. Which option should he implement?
    9·2 answers
  • 1. Pasar los siguientes ejercicios a diagrama de bloque
    11·1 answer
  • Write a program that reads in exam scores and displays the average score and the high score.
    9·1 answer
  • 8.6 Code Practice: Question 2
    7·1 answer
  • Need help finding the totals and with the empty spots
    9·1 answer
  • NAT addresses concerns over the dwindling IPv4 address space by ___________________. 1 point allowing networks to use fewer IP a
    15·1 answer
  • A classic game, Wario Land, has an invincible main character who reacts to the environment in order to solve puzzles. So, for ex
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!