Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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
Then the sorted version of anArray would be:
sortedArray
And reversing the sorted array would be:
reversedSorted
Using the IDE of your choice JGrasp is strongly recommended create the java class depicted in
the below UML diagram. Refer to CS lectures or the book for details about methods that
receive an argument andor return a reference variable to an array. UML diagrams are explained in
lecture of my cs course. Helpful video regarding UML diagrams
ArrayProcessor
sortThreeIntArrayanArray : int : int
reverseThreeIntArrayanArray : int : int
printThreeIntArrayanArray : 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
Page of CS Intro. Programming Fundamentals II CWU, Tatiana Harrison, Lab
sortThreeIntArray returns a reference to an int array that contains the sorted, from
smallest to largest, entries in the receiving anArray.
Hint : 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 : there are many ways to sort an array, which youll learn about in CS and CS
However, you dont 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 youll be creating will have only
entries. You can enumerate all of the possible combinations of entries in anArray using an if
else loop. For example, if the input array has entries then youd check whether and
then whether and perform swapping when necessary to rearrange the entries to 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. Youll need
to import the Random class and generate numbers with an upper bound.
create an array, anArray, of ints
create an instance of the Random class
create an instance of the ArrayProcessor class
generate a random number between and and place it into the th index of anArray
generate a random number between and and place it into the st index of anArray
generate a random number between and and place it into the nd index of anArray
invoke the printThreeIntArray method of the ArrayProcessor class and print the anArray entries
invoke sortThreeIntArray method of the ArrayProcessor class, and print the sorted array
invoke the reverseThreeIntArray method of the ArrayProcessor class, and print the reversed array
III. Sample Invocation
Three sample invocations of the program are shown below.
The original array
Entry is
Entry is
Entry is
The sorted array
Entry is
Entry is
Entry is
The sorted reversed array
Entry is
Entry is
Entry is
The original array
Entry is
Entry is
Entry is
The sorted array
Entry is
Entry is
Entry is
The sorted reversed array
Entry is
Entry is
Entry is
The original array
Entry is
Entry is
Entry is
The sorted array
Entry is
Entry is
Entry is
The sorted reversed array
Entry is
Entry is
Entry is
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