SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 1 Day Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 20 Nov 2017 My Price 10.00

ArrayProcessor class contains three methods.

I want to know how to write the  two .java files code.

 

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:

4

7

1

 

 

 

1

4

7

 

 

 

7

4

1

anArray =

Then the sorted version of anArray would be:

sortedArray =

And reversing the sorted array would be:

reverseSorted =

Using the IDE of your choice, create the .java class depicted in the below UML diagram. Refer to sections 7.4 and 7.5 of the textbook for details about methods that receive an argument and/or return a reference variable to an array. UML diagrams are explained in section 6.2 of the book.

 

ArrayProcessor

               

+ sort3IntArray(anArray : int[]) : int[]

+ reverse3IntArray(anArray : int[]) : int[]

+ print3IntArray(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

sort3IntArray 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 sort3IntArray and reverse3IntArray, 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. 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 if-else loop. For example, if the input array has entries 1, 6, 3, then you’d check whether 1 < 6, and then whether 6 < 3, and perform swapping when necessary to rearrange the entries to 1, 3, 6.

 

I.      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 (see section 4.11 of the textbook).

 

 

// create an array, anArray, of 3 ints

// create an instance of the Random class

 

// generate a random number between 0 and 10, and place it into the 0th  index of anArray

// generate a random number between 0 and 10, and place it into the 1st  index of anArray

// generate a random number between 0 and 10, and place it into the 2nd  index of anArray

 

// invoke the print3IntArray method of the ArrayProcessor class and print the anArray entries

// invoke sort3IntArray method of the ArrayProcessor class, and print the sorted array

// invoke the reverse3IntArray method of the ArrayProcessor class, and print the reversed array

 

 

 

 

 

 

 

 

 

 

 

II.      Sample Invocation

 

Three sample invocations of the program are shown below.

 

The original array

Entry 0 is 8

Entry 1 is 2

Entry 2 is 9

 

The sorted array Entry 0 is 2

Entry 1 is 8

Entry 2 is 9

 

The sorted reversed array

Entry 0 is 9

Entry 1 is 8

Entry 2 is 2

 

The original array

Entry 0 is 6

Entry 1 is 5

Entry 2 is 6

 

The sorted array Entry 0 is 5

Entry 1 is 6

Entry 2 is 6

 

The sorted reversed array

Entry 0 is 6

Entry 1 is 6

Entry 2 is 5

 

The original array

Entry 0 is 7

Entry 1 is 5

Entry 2 is 0

 

The sorted array Entry 0 is 0

Entry 1 is 5

Entry 2 is 7

 

The sorted reversed array

Entry 0 is 7

Entry 1 is 5

Entry 2 is 0

 

                                                                                                                                                                                                  

Attachments:

Answers

(5)
Status NEW Posted 20 Nov 2017 06:11 AM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)