Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this lab, you will create one class named ArrayFun.java which will contain a main method and 4 static methods that will be called from

In this lab, you will create one class named ArrayFun.java which will contain a main method and 4 static methods that will be called from the main method.

The process for your main method will be as follows:

Declare and create a Scanner object to read from the keyboard

Declare and create an array that will hold up to 100 integers

Declare a variable to keep track of the number of integers currently in the array

Call the fillArray method described below, passing the appropriate arguments and storing the result in the appropriate variable.

Call the computeProduct method described below, passing the appropriate arguments, and print the result to the screen with an appropriate label

Ask the user for an integer and store in a variable named factor

Use the countMultiples method described below to compute the number of multiples of that factor and print the result with an appropriate label

Use the printArray method to print out the values in the array

fillArray

The static fillArray method will accept two parameters: an integer array and a Scanner. It must ask the user for values to add to the array, beginning at index 0, stopping when the user enters -999. Make sure that the -999 is not included in the array. The method will return the number of values put into the array.

computeProduct

The static computeProduct method will accept two parameters: an integer array and an integer representing the number of valid values in the array. The method will return the product of the integers in the array. Note: test this with relatively small values or short arrays.

countMultiples

The static countMultiples method will accept three parameters: an integer array, an integer representing the number of valid values in the array, and an integer representing a factor. The method will count the number of valid values in the array that are multiples of the factor and will return the count.

printArray

The static printArray method will accept two parameters: an integer array and an integer representing the number of valid values in the array. The method will print the valid values from the array to the screen, one per line.

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

Students also viewed these Databases questions