
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 nowThis is a popular solution!
Step by stepSolved in 2 steps with 3 images

- 1. Write a program that calls a method that takes a character array as a parameter (you can initialize an array in the main method) and returns the number of vowels in the array. Partial program is given below. public class CountVowels{ public static void main(String[] args){ char[] arr= System.out.print("There are "+vowels(arr)+" vowels in the array");arrow_forwardMethod Details: public static java.lang.String getArrayString(int[] array, char separator) Return a string where each array entry (except the last one) is followed by the specified separator. An empty string will be return if the array has no elements. Parameters: array - separator - Returns: stringThrows:java.lang.IllegalArgumentException - When a null array parameter is providedarrow_forwardThe programming language used is Javaarrow_forward
- java a. A method named contains exists that takes an array of Strings and a single String, in that order, as arguments and returns a boolean value that is true if the array contains the given String. Assume that an array of Strings named names is already declared and initialized. Call the method to see if the array contains the name "Fred", and save the result in a new variable named fredIsHere. b. Given a method named printMessage that takes a String argument and returns nothing, call the method to print out "I love Java!".arrow_forwardUsing Java, Define a method named sortArray that takes an array of integers and the number of elements in the 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 of integers from input, stores the integers in an array, calls sortArray(), and outputs the sorted array. The first input integer indicates how many numbers are in the list. Assume that the list will always contain less than 20 integers. Ex: If the input is: 5 10 4 39 12 2 the output is: 39,12,10,4,2, For coding simplicity, follow every output value by a comma, including the last one. Your program must define and call the following method:public static void sortArray(int[] myArr, int arrSize)arrow_forwardIn JAVA Write the method below: Given a two-dimensional array containing integers, create a method called "matrixOperations" The method should do the following:1. Print out all the numbers in the array row by row (add empty line at the end of the row)2. For each row, print out the length of the row (each row is an array, remember)arrow_forward
- The programming language used is Javaarrow_forwardWrite a static method that displays all combinations of picking two numbers from the array list: public static void combinations(ArrayList<Integer> list) Include the driver program that prompts the user to enter 10 integers and displays all combinations of picking two numbers from the array list.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





