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
Please submit the following assignment prior to Sunday at 11:59 pm. Eastern time: 1. Using a Microsoft Word document, please dis
GenaCL600 [577]

Answer:

Answer explained

Explanation:

United States of America versus Ross Ulbrecht :-

The Fourth Amendment guards against unreasonable searches and seizures by requiring (with limited exceptions) that government agents first obtain a warrant before they go snooping around or confiscating someone’s property. But what exactly does this mean in the modern world of smart phones, wi-fi, and extended Socratic dialogues with Siri? If the New York-based U.S. Court of Appeals for the Second Circuit is to be believed, it means that the government can monitor and collect your internet traffic if this information is merely “likely” to be “relevant” to an ongoing criminal investigation.

That is exactly what happened to Ross Ulbricht, the creator of a website known as “Silk Road,” which enabled users to anonymously buy and sell goods and services. In the course of an investigation into illegal activities associated with the website, the government obtained five “pen/trap” orders authorizing law enforcement to collect IP (internet protocol) addresses for any internet traffic going to or from Ulbricht’s wireless router and other electronic devices. These orders were obtained in lieu of a warrant under a statutory “relevance” standard that falls well short of the Fourth Amendment’s requirement for probable cause.

How could this standard possibly not be constitutionally insufficient? The Second Circuit relied on the “third party doctrine,” ruling that there was no Fourth Amendment issue because users voluntarily conveyed their information to ISPs (internet service providers) and third-party servers, and thus assumed the risk that it would later be turned over without their permission or knowledge. This doctrine, which was developed in the days of pay phones and file cabinets, cannot be fairly extended to online activity given that internet access is—for all intents and purposes—a necessity of modern life for any functioning member of society. Recognizing this simple fact undermines any claim that users have somehow assumed the risk of disclosure to the government, which would have assumed that these users had any real choice in the matter to begin with.

The court also reasoned that because pen/trap devices only reveal IP addresses associated with the user’s online browsing, the collected information doesn’t count as “content” worthy of protection—despite the direct correlation between individual IP addresses and websites, along with the ample information that can be gleaned from knowledge of an individual’s browsing history. The court seemed to conclude that there was no content revealed because an IP address only uncovers the website visited rather than any individual webpage within that site. This superficial approach utterly ignores digital reality.

Finally, the court failed to recognize that the statute authorizing pen/trap data seizure imposes virtually no limits on government attorneys’ discretion. These orders are exceedingly broad in scope and available to nearly any government agency conducting a criminal investigation. Worse still, the court’s role in approving the orders is merely ministerial, with the statute mandating that “the court shall enter an ex parte order authorizing the installation” of these devices.

Because the Second Circuit has stretched both the third-party doctrine and the content/non-content distinction far beyond their logical limitations, Cato—along with the Reason Foundation, Competitive Enterprise Institute, and R Street Institute—has filed an amicus brief asking the Supreme Court to take this case and firmly establish that the internet doesn’t constitute some sort of Constitution-free zone.

5 0
3 years ago
Alex’s family members live in different parts of the world. They would like to discuss the wedding plans of one of their distant
goldenfox [79]
The answer would be b
8 0
4 years ago
Read 2 more answers
. Write a function definition as follows: it returns the C++ form of a Boolean value, its function identifier is anyTwoTheSame,
Paraphin [41]

Answer:

The c++ code to implement the Boolean function is given. The function definition is shown.

bool anyTwoTheSame(float a, float b, float c)

{

   bool same = false;    

   if(a == b)

       same = true;

   else if(a == c)

       same = true;

   else if(b == c)

       same = true;        

   return same;

}

Explanation:

This function accepts three floating point numbers and returns true if any two numbers are equal else returns false.

The program below shows the implementation of this method.

#include <iostream>

using namespace std;

bool anyTwoTheSame(float a, float b, float c);

bool anyTwoTheSame(float a, float b, float c)

{

   bool same = false;    

   if(a == b)

       same = true;

   else if(a == c)

       same = true;

   else if(b == c)

       same = true;        

   return same;

}

int main() {    

   float one=12.34, two=56.78, three=90.1;    

   cout<<"Two numbers are same : " <<anyTwoTheSame(one, two, three);

}

OUTPUT

Two numbers are same : 0

The method is first declared.

bool anyTwoTheSame(float a, float b, float c);

Next step is method definition which shows what the function is supposed to do. The test to check equality of two numbers is implemented as shown.

bool same = false;    

if(a == b)

       same = true;

   else if(a == c)

       same = true;

   else if(b == c)

       same = true;  

This is the simplest test which can be programmed.

If the numbers are not same, the Boolean variable, same, remains initialized to false.

This function is then called in main method.

No user input is taken as this is not specified in the question.

The three floating variables are declared and initialized inside the main. The values are put inside the program and not taken from the user.

The output shows either 0 or 1. 0 represents false and 1 represents true.

This program can be tested for different values of floating variables.

3 0
3 years ago
Hello guys where's bios chip in this motherboard ​
dolphi86 [110]

Answer: This. is an old Asus Board and the chip is missing

Explanation: The BIOS chip goes into the Processor holder. the one with the curved metal arm to help release it (goes into the cage first you use glue made for ) installing the chip, then you place the processor on top of that big part where it resembles a slice of bread.  You lock down the four legs and that is the brain of the MB.

To update the BIOS,in the machine outside of the operating system. ON WIndows it is the command center on Mac it is different.

The CMOS Battery is next to the word ASUS .

The BIOS is code and software that you upload from the manufacturer's site like ASUS.  and in the command environment, you update the bios.

The CHIP is delicate and it ONLY GOES  on ONE WAY! BE Verry very careful installing the chip and processor better to have a pro (like me ) do it ...

Motherboards are very delicate and expensive! All parts go one way and one way only. Be glad you don't have to Sauter anything.

3 0
1 year ago
Alan is a manager at a company that is implementing new enterprise systems. What function performed in his company would be cons
Gre4nikov [31]

the answer should be A thats what best fits

6 0
3 years ago
Other questions:
  • A password checking system that disallows user passwords that are proper names or words that are normally included in a dictiona
    15·1 answer
  • Dom is a software developer who likes to tweak his computer's OS to make it work the way he wants it to. The OS he is most likel
    14·1 answer
  • 10^4+10-2=<br>10^4+10-2=
    12·2 answers
  • What kind of programming language allows you to use a vocabulary of reasonable terms such as "read," "write," or "add" instead o
    13·1 answer
  • Which line in the following program will cause a compiler error?
    9·1 answer
  • Write the simulate method, which simulates the frog attempting to hop in a straight line to a goal from the frog's starting posi
    10·1 answer
  • Why are there problems with patching electronics such as heart rate monitors and MRI machines that run embedded Windows OSs?
    14·1 answer
  • The point of (18 ,0) lies on​
    15·2 answers
  • What are the steps to view two different versions of the same document at once? 1. Go to the File tab on the ribbon. 2. Select T
    6·1 answer
  • What statement is accurate in regards to
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!