Question: Write a java program using the following instructions: Write a program that uses methods to do the following array manipulations. Your program will create a

Write a java program using the following instructions:

Write a program that uses methods to do the following array manipulations. Your program will create a one dimensional array and store random numbers in the array. You will also create a second array that has the same numbers in the reverse order. Main should only consist of variable declarations, method calls, and print statements. An outline of main is as follows , you must include these comments:

final int maxnums = 30;

//declare a constant for size of array

//declare two one dimensional arrays the size of maxnums

//and any other variables needed

//call initArray to store numbers in array

//call printArray to print the array with 5 numbers per row

//call findMax to determine max

//call findMin to determine min

//call findAvg to determine average

//print minimum, maximum, average

//call reverseArray to store numbers in second array

//in reverse order

//call printArray to print the reversed array with 7 numbers per row

Create the following methods that receive and process arrays:

initArray Receives an array as parameter. Stores random numbers in the range of 1 to 999 in the array.

printArray Receives an array and the number of values to print per row (columns) as parameters. Print the values in the array with the specified number of values (columns) per row. Use a counter to keep track of how many values have been printed and determine when to move to the next line. Do not use nested loops!

findMax Receives an array as parameter. Determine the maximum value of the array and return that value.

findMin Receives an array as parameters. Determine the minimum value of the array and return that value.

findAvg Receives an array as parameter. Determine the average of the numbers and return that value.

reverseArray Receives two arrays as parameters. Copy one array to another in reverse order. Note that it actually stores the values in a second array. This method does not print values. Follow the outline for main.

SAMPLE OUTPUT: (Numbers will be different due to random number generator)

The numbers are:

176 941 752 344 73

543 582 644 330 357

560 25 13 482 336

607 456 756 416 347

911 439 912 714 242

601 985 396 649 303

The largest number is 985

The smallest number is 13

The average is 496.4

The reversed numbers are:

303 649 396 985 601 242 714

912 439 911 347 416 756 456

607 336 482 13 25 560 357

330 644 582 543 73 344 752

941 176

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!