Question
The ArrayProcessor class contains three methods. The first method named printArray , this method prints out the contents of an array. One way to print
The ArrayProcessor class contains three methods. The first method named printArray , this method prints out the contents of an array. One way to print out the contents of an array is to use a for loop and iterate through the array, printing out the elements one by one. The second method sortArray , sorts the array. There are several standard and efficient ways to sort an array, which youll learn in later courses. For now you can just use a brute force approach, simply just check the v alues one against another. The last method named reverseArray , reverses the sorted array. Assume that you have an array named x with the values 2, 1, 3. If you were to sort the values in x , then you would get 1, 2, 3. And if you were to reverse the sorted array, you would get 3, 2, 1.
Write the class ArrayProcessor. The methods sortArray and reverseArray will return a reference to an int array. Declare variables of the appropriate type as needed. The ArrayProgram class will be the driver class. In this class you will generate the random numbers, populate an array, create an instance of ArrayProcessor and call the methods to sort the array. Remember to import the Random class in order to gen erate random numbers. The pseudocode for this class is below.
Create an array of 3 ints
Create an instance of the Random class
Create an instance of the ArrayProcessor class
Generate a random number between 0 and 100, and place into the array at indexlocation 0
Generate a random number between 0 and 100, and place into the array at index location 1
Generate a random number between 0 and 100, and place into the array at index location 2
Invoke the printArray method of the ArrayProcessor class
Invoke
the sortArray method of the ArrayProcessor class
Invoke the printArray again to now print out the sorted array
Invoke the reverseArray method of the ArrayProcessor class
Invoke the printArray method
one more time to print out the sorted array reversed
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started