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
DaniilM [7]
3 years ago
5

Write a function named minMax() that accepts three integers arguments from the keyboard and finds the smallest and largest integ

ers. Include the function minMax() in a working program. Make sure your function is called from main().Test the function by passing various combinations of three integers to it.
Computers and Technology
1 answer:
Bad White [126]3 years ago
5 0

Answer:

public class Main

{

public static void main(String[] args) {

 minMax(1, 2, 3);

 minMax(100, 25, 33);

 minMax(11, 222, 37);

}

public static void minMax(int n1, int n2, int n3){

    int max, min;

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

        max = n1;

    }

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

        max = n2;

    }

    else{

        max = n3;

    }

   

    if(n1 <= n2 && n1 <= n3){

        min = n1;

    }

    else if(n2 <= n1 && n2 <= n3){

        min = n2;

    }

    else{

        min = n3;

    }

    System.out.println("The max is " + max + "\nThe min is " + min);    

}

}

Explanation:

*The code is in Java.

Create a function named minMax() that takes three integers, n1, n2 and n3

Inside the function:

Declare the min and max

Check if n1 is greater than or equal to n2 and n3. If it is set it as max. If not, check if n2 is greater than or equal to n1 and n3. If it is set it as max. Otherwise, set n3 as max

Check if n1 is smaller than or equal to n2 and n3. If it is set it as min. If not, check if n2 is smaller than or equal to n1 and n3. If it is set it as min. Otherwise, set n3 as min

Print the max and min

Inside the main:

Call the minMax() with different combinations

You might be interested in
The while loop has two important parts: an expression that is tested for a true or false value, and:
agasfer [191]

Answer:

The correct answer for the given question is option(A) i,e a statement or block that is repeated as long as the expression is true.

Explanation:

While loop is an entry control loop it means if the condition in while loop is true then the statement inside the while loop is executed untill condition of while loop is false .

Following are the syntax of while loop

while(condition checking)

{

// statement

// increment or dec variable;

}

Let us consider an example of while loop

Following are the program in c++

#include<iostream> // header file

using namespace std; //namespace

void main() // main method

{

int k=1; // variable declarartion

while(k<5) // iterating over loop

{

cout<<"hello brainly:";

k++; // increment of k by 1

}

}

In the following code the variable k is initialized by 1 so 1<5 condition is "true" it executed the statement  inside the loop that menas when k=1 it print hello brainly: after printed the message  hello brainly: it increment the value of k by 1, Now k becomes "2" again 2<5 condition is "true "it executed the statement again .This process will continue untill k=5 when k=5 the condition is "false" it terminate the while loop.

Output

hello brainly:hello brainly:hello brainly:hello brainly:hello brainly:

5 0
4 years ago
Short Essay on the history of Computer​
Ann [662]
Go on a essay website the right a essay about a topic !
5 0
3 years ago
Read 2 more answers
What do these terms have in common? google, yahoo!, bing they are important books. they are internet search engines. they are wo
Vlada [557]
They are Internet search engines.
7 0
4 years ago
A wired laser printer is attached to a home computer. That printer has been shared so that other computers on the home network c
ohaa [14]

Answer:

peer-to-peer (P2P)

Explanation:

P2P peer-to-peer networking model is in use

3 0
3 years ago
What is the full form of ms-word?​
Alex

Answer:

microsoft word

Explanation:

i got certified on it sooooooooooo...

6 0
3 years ago
Read 2 more answers
Other questions:
  • Provide the code to insert a subtitle track named "Spanish Version" using the track text in the spanish.vtt file and the Spanish
    9·1 answer
  • An application that can be launched from my web browser is known as a _____. java applet spreadsheet cad software music applicat
    14·1 answer
  • Which image format is good for compressing large, complex images like photos into smaller file sizes?
    5·1 answer
  • Visme,PowerPoint, keynote and prezi are what kind of software
    15·1 answer
  • Plz answer -----------
    11·2 answers
  • Fix the two words that are used incorrectly.
    10·2 answers
  • Click print to publish your post in a blog true or false.​
    5·2 answers
  • Firestick optimizing system storage and applications loop
    12·1 answer
  • Select the correct answer.
    13·1 answer
  • i installed windows 11 all looks ok except my ebay and some other sites are all white with black text no highlights or color???
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!