Question: II . The ArrayProcessor Class The ArrayProcessor class contains three methods. One prints the contents of an array, another sorts the contents of an array,

II. The ArrayProcessor Class
The ArrayProcessor class contains three methods. One prints the contents of an array, another sorts the contents of an array, and the third reverses the contents. The class is meant to process arrays of three ints For example, if:
anArray ={:[4,15,1]
Then the sorted version of anArray would be:
sortedArray ={:[1,4,15]
And reversing the sorted array would be:
reversedSorted ={:[15,4,1]
Using the IDE of your choice (JGrasp is strongly recommended), create the java class depicted in the below UML diagram. Refer to CS110 lectures or the book for details about methods that receive an argument and/or return a reference variable to an array. UML diagrams are explained in lecture 19 of my cs 110 course. Helpful video regarding UML diagrams
\table[[ArrayProcessor],[],[+ sortThreeIntArray (anArray : int []) : int []],[+ reverseThreeIntArray (anArray : int[]) : int[]],[+ printThreeIntArray (anArray : int[]) : void]]
Each of the three methods receives as an argument a reference variable to an array of integers. Two of the methods return a reference variable to an array object. The method
sortThreeIntArray returns a reference to an int array that contains the sorted, from smallest to largest, entries in the receiving anArray.
Hint 1: for each of the methods sortThreeIntArray and reverseThreeIntArray, create an int array for use in that method, and populate it with entries that you retrieve from the receiving anArray object.
Hint 2: there are many ways to sort an array, which you'll learn about in CS301 and CS302. However, you don't need a fancy algorithm to sort a small array; it can be done using a brute force approach, especially in this case because the input array that you'll be creating will have only 3 entries. You can enumerate all of the possible combinations of entries in anArray using an ifelse loop. For example, if the input array has entries 1,6,3, then you'd check whether 16, and then whether 63, and perform swapping when necessary to rearrange the entries to 1,3,6. You are not allowed to use the Sort method.
II. The ArrayProgram class
Write a class, ArrayProgram, with a main routine that has the below pseudocode. You'll need to import the Random class and generate numbers with an upper bound.III. Sample Invocation
Three sample invocations of the program are shown below.
\table[[The original array],[Entry 0 is 81],[Entry 1 is 23],[Entry 2 is 95],[],[The sorted array],[Entry 0 is 23],[Entry 1 is 81],[Entry 2 is 95],[],[The sorted reversed array],[Entry 0 is 95],[Entry 1 is 81],[Entry 2 is 23]]
\table[[The original array],[Entry 0 is 63],[Entry 1 is 5],[Entry 2 is 63],[],[The sorted array],[Entry 0 is 5],[Entry 1 is 63],[Entry 2 is 63],[],[The sorted reversed array],[Entry 0 is 63],[Entry 1 is 63],[Entry 2 is 5]]
II . The ArrayProcessor Class The ArrayProcessor

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!