Question: Create a new Java class, LX6. Download the class ArrayManager.java and copy its source code into LX6, changing the class name where necessary. Then fill

Create a new Java class, LX6. Download the class ArrayManager.java and copy its source code into LX6, changing the class name where necessary. Then fill out the method shells in LX6 with the specifications below. After creating the methods 2) through 5), test them by running the application. The main method allows users to enter a command and, when necessary, additional command specifications.

ArrayManager.java

1) a method displayArray:

accepts as a parameter an int array named data

prints the array elements to the console, separated by commas and spaces, with the entire array enclosed in braces, e.g., the array [0, 1, 2] should display as {0, 1, 2}

2) a method expandIntArray:

accepts as a parameter an int array named data

creates a new int array twice as large as data

copies every int value from data into the same index in the new array

the other indexes in the new array should be zeroes

returns the new array

3) a method shrinkIntArray:

accepts as a parameter an int array named data

creates a new int array half as large as data

for every index in the new array, copies the corresponding int value from data into it

returns the new array

4) a method insertValue:

accepts as parameters an int array named data, an int named value, and an int named index

creates a new array one element larger than data

for every index < index, copies the value from data into the new array

copies value into the new array's index element

for every index > index, copies the value from data into the new array's next index, i.e., copies from index x in data to index x+1 in the new array

returns the new array

5) a method removeValue:

accepts as parameters an int array named data and an int named index

creates a new array one element smaller than data

for every index < index, copies the value from data into the new array

for every index > index, copies the value from data into the new array's previous index, i.e., copies from index x in data to index x-1 in the new array

returns the new array

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 Databases Questions!