Question: Create a Java class called TotalArray that sums the value of an array. This class should have a main method, sumArray method, and createRandomArray method.

Create a Java class called TotalArray that sums the value of an array. This class should have a main method, sumArray method, and createRandomArray method. The main method should accept the size of an array and a bound from the user and print the random array and the sum of the random array. The createRandomArray should create an array of random numbers. This method should accept the size of an array and a bound. The method should return an array of random numbers. The sumArray method should calculate the sum of a random array. This method should accept a random array generated by the createRandomArray method and return the sum of the array.

Note: All method calls should be done in the main.

An example of the program input and output is shown below:

Enter an array size: 10

Enter a bound: 10

The random array is [2, 4, 6, 2, 9, 1, 4, 5, 5, 6]

The sum of the random array is 44

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!