Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 19 -- ArrayUtilities In Eclipse, create a project called Lab19. Create a class called ArrayUtilities. Write each method described below (in the ArrayUtilities class).

Lab 19 -- ArrayUtilities

In Eclipse, create a project called Lab19. Create a class called ArrayUtilities.

Write each method described below (in the ArrayUtilities class). After writing the method, write some JUnit tests that check to see if it works properly.

Write a public, static method called blueToRed, with return type void. The method accepts one parameter, which is an array of String references. The method will replace all entries in the array that say blue with ones that say red. (Note that this is a destructive method it modifies the state of the parameter.)

Write a public, static method called intArrayFactory, which returns an array of ints. The method will have one parameter, which is an integer called n. The return value should be an array of length n that is filled with the integers from 1 through n.

For example, if n is 7, then the return value would be an array containing these values:

[1, 2, 3, 4, 5, 6, 7]

Write a public, static method called duplicator, which returns an array of doubles and accepts an array of doubles as a parameter. The method will return an array that contains all the same elements as the parameter, but listed twice.

For example, if the parameter is the array [2.4, 9.6, 177.5] then the return value should be: [2.4, 9.6, 177.5, 2.4, 9.6, 177.5]

Write a public, static method called sevenRemover, which returns an array of ints. The method will have one parameter, which is an array of integers. The return value will be an array that contains of all the same values that are contained in the parameter, but without any sevens.

For example, if the parameter looks like the array [5, 7, 2, 7, 8, 1, 3, 7 , 7, 4] then the return value should be the array [5, 2, 8, 1, 3, 4].

Write a public, static method called primeGenerator, which returns and array of ints. The method will take one parameter, which is an int called count. The method will return an array containing count number of primes.

For example, if count is equal to 7, then the return value should be an array containing the first 7 primes:

[2, 3, 5, 7, 11, 13, 17]

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

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago