Define a method named sortArray that takes an array of integers and the number of elements inthe array as parameters. Method sortArray() modifies the array parameter by sorting the elements in descending order (highest to lowest). Then write a main program that reads a list ofintegers from input, stores the integers in an array, calls sortArray(), and outputs the sortedarray. The first input integer indicates how many numbers are in the list. Assume that the list willalways contain less than 20 integers.Ex: If the input is:5 10 4 39 12 2the output is:39,12,10,4,2,For coding simplicity, follow every output value by a comma, including the last one.Your program must de±ne and call the following method:public static void sortArray(int[] myArr, int arrSize)
Define a method named sortArray that takes an array of integers and the number of elements inthe array as parameters. Method sortArray() modifies the array parameter by sorting the elements in descending order (highest to lowest). Then write a main program that reads a list ofintegers from input, stores the integers in an array, calls sortArray(), and outputs the sortedarray. The first input integer indicates how many numbers are in the list. Assume that the list willalways contain less than 20 integers.Ex: If the input is:5 10 4 39 12 2the output is:39,12,10,4,2,For coding simplicity, follow every output value by a comma, including the last one.Your program must de±ne and call the following method:public static void sortArray(int[] myArr, int arrSize)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 3 images