Question

In: Computer Science

Using the Math.max() and Math.min() functions (along with whatever else you've been taught in lecture so...

Using the Math.max() and Math.min() functions (along with whatever else you've been taught in lecture so far) write a function that accepts three integers and prints them in either ascending or descending order.

Starter code for this function is included below, though you are welcome to write it from scratch:

public class Main {

  public static void main( String[] args ) {

    sortInts( 321, 654, 987 );

  }

public static void sortInts( int arg1, int arg2, int arg3 ) {

    int highVal; // HH

    int midVal; // MM

    int lowVal; // SS

    <TODO> - Implement this function>

    System.out.println( highVal + " " + midVal + " " + lowVal );

  }

}

  

  

Solutions

Expert Solution

public class Main {

          public static void main( String[] args ) {

            sortInts( 4321, 654, 987 );

          }

        public static void sortInts( int arg1, int arg2, int arg3 ) {

            int lowVal=arg1; // HH

            int midVal=arg2; // MM

            int highVal=arg3; // SS

            if(lowVal>midVal) {
                        int temp=lowVal;
                        lowVal=midVal;
                        midVal=temp;
                }
                if(midVal>highVal) {
                        int temp=midVal;
                        midVal=highVal;
                        highVal=temp;
                }
                if(lowVal>midVal) {
                        int temp=lowVal;
                        lowVal=midVal;
                        midVal=temp;
                }
            System.out.println( lowVal + " " + midVal + " " + highVal );

          }

        }


NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.

I AM HERE TO HELP YOUIF YOU LIKE MY ANSWER PLEASE RATE AND HELP ME IT IS VERY IMP FOR ME


Related Solutions

The following data represent exam scores in a statistics class taught using traditional lecture and a...
The following data represent exam scores in a statistics class taught using traditional lecture and a class taught using a​ "flipped" classroom. Complete parts​ (a) through​ (c) below. Traditional 71.071.0 69.969.9 80.580.5 67.567.5 84.384.3 77.677.6 57.057.0 82.582.5 81.281.2 70.970.9 64.364.3 70.370.3 60.160.1 Flipped 76.776.7 71.771.7 64.064.0 72.672.6 77.577.5 90.990.9 79.879.8 77.277.2 81.681.6 69.269.2 92.592.5 77.777.7 75.775.7 ​(a) Which course has more dispersion in exam scores using the range as the measure of​ dispersion? The traditional course has a range of...
The following data represent exam scores in a statistics class taught using traditional lecture and a...
The following data represent exam scores in a statistics class taught using traditional lecture and a class taught using a​ "flipped" classroom. Complete parts​ (a) through​ (c) below. Traditional 71.7 69.2 78.7 68.1 84.1 78.5 56.9 81.0 82.0 72.3 63.7 69.0 60.5 Flipped 76.8 72.0 64.0 73.0 78.8 92.5 79.2 77.4 81.8 71.2 91.4 78.5 75.9 ​(a) Which course has more dispersion in exam scores using the range as the measure of​ dispersion? The traditional course has a range of...
he following data represent exam scores in a statistics class taught using traditional lecture and a...
he following data represent exam scores in a statistics class taught using traditional lecture and a class taught using a​ "flipped" classroom. Complete parts​ (a) through​ (c) below. Traditional 71.471.4 69.169.1 80.480.4 68.368.3 85.385.3 79.379.3 56.656.6 81.681.6 80.180.1 71.571.5 63.163.1 69.169.1 59.959.9 Flipped 77.077.0 70.970.9 62.662.6 71.471.4 77.577.5 91.891.8 79.979.9 77.277.2 81.681.6 69.269.2 92.692.6 77.877.8 76.476.4 ​(a) Which course has more dispersion in exam scores using the range as the measure of​ dispersion? The traditional course has a range of...
Why has it been so difficult for neuropsychologists to discover the functions of the right hemisphere?
Why has it been so difficult for neuropsychologists to discover the functions of the right hemisphere?
Solve using PYTHON 3 and use functions. You have been hired by a restaurant named "Burger...
Solve using PYTHON 3 and use functions. You have been hired by a restaurant named "Burger Shack" Per the client, you have the following information: the client’s name, burger’s name, time of the day, and the total bill. By the end of the day, your program will provide the following information: 1. Top three best clients (highest bills) 2. Name of the client with the second-to-last lowest bill 3. Busiest hour of the day (number of clients) Assumptions: 1. doesn't...
Assume the following functions have already been defined, write a main() using c++ that uses them...
Assume the following functions have already been defined, write a main() using c++ that uses them to fill a vector with random integers, remove the smallest and largest integers from the vector, save the result in a file called "trimmed.txt" void fillRandom(vector & nums, int howMany); // fill with specified number of integers int minValue(vector nums); // return smallest value in vector int maxValue(vector <;int> nums); // return largest value in vector void writeFile(string outFileName, vector nums ); // writes...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT