Write method print that takes an integer array as an input


1. Write method print that takes an integer array as an input parameter and prints all the numbers in the array separated by commas. Name your program ArrayTest.java.

2. Write method average that takes an integer array as an input parameter and returns the average of all numbers in the array. Define this method in ArrayTest.java as well.

3. Write method max that takes an integer array as an input parameter and returns the maximum number in the array. Define this method in ArrayTest.java also.

4. Write a main method. Define several arrays, print the content of the array, the average of the array, and the maximum number in the array. Below is my main method:

int[] nums = {14, 1, 23};

System.out.println("My first array is: ");

print(nums);

System.out.println("The average of the array is: " + average(nums));

System.out.println("The maximum number in the array is: " + max(nums));

System.out.println("");

int[] nums2 = {11, 26, 4, 2};

System.out.println("My second array is: ");

print(nums2);

System.out.println("The average of the array is: " + average(nums2));

System.out.println("The maximum number in the array is: " + max(nums2));

5. Create zip file that contains your Java programs. Include a screenshot of each program execution. You can either paste the screenshot into a Word document or simply paste it into the Comments field when submitting your homework. A sample screenshot of running my programs is attached below:

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Write method print that takes an integer array as an input
Reference No:- TGS02687220

Now Priced at $30 (50% Discount)

Recommended (98%)

Rated (4.3/5)