Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Concepts, Theories, And Applications

Authors: Shui Yu, Song Guo

1st Edition

3319277634, 9783319277639

More Books

Students also viewed these Databases questions