Question: To write the Java programs that use methods and arrays. Problem 1: Complete the following java program which creates an array of 20 elements.

To write the Java programs that use methods and arrays. Problem 1:

 Complete the following java program which creates an array of 20 elements.

To write the Java programs that use methods and arrays. Problem 1: Complete the following java program which creates an array of 20 elements. The program then should do the following: 1. Initialize the elements of the array to random numbers between 0 and 100. 2. Display the content of the array (i.c., 20 random numbers). 3. Display the smallest number in the array. 4. Display the smallest number in the array. 5. Calculate and display the average of all the numbers. 6. Reverse the array and display it (Do not use a second array to reverse the array, only reuse a temporary variable) public class ArrayDemo { public static void main(String[] args) { int[] numbers = new int[20]; initializeArray (numbers) System.out.println("The array of random numbers is:"); displayArray (numbers); " System.out.println("The smallest number in the array is + getSmallest (numbers)); System.out.println("The average of the array elements is " + getAverage (numbers)); System.out.println("The number of elements above average is + countAboveAverage (numbers)); reverseArray (numbers); System.out.println("The array of random numbers in reverse is:"); displayArray (numbers); Sample Outputs: The array of random numbers is: 86 25 28 60 15 78 86 81 68 The smallest number in the array is 15 The average of the array elements is 56.4 The number of elements above average is 12. The array of random numbers in reverse is: 39 91 74 76 66 37 87 30 68 The array of random numbers is: 61 7 61 91 39 17 47 34 The smallest number in the array is 1 The average of the array elements is 47.0 The number of elements above average is 9 The array of random numbers in reverse is: 21 1 86 6 17 83 74 79 84 The array of random numbers is: 65 11 9 89 99 69 25 Hand In: 21 20 60 30 87 37 66 76 20 21 68 81 86 78 15 73 34 84 79 74 83 17 6 34 73 25 34 47 17 39 The array of random numbers in reverse is: 25 58 62 94 47 17 3 76 69 64 27 83 65 40 69 99 74 91 39 60 28 25 86 86 1 21 40 65 83 27 64 69 76 3 17 47 94 62 58 25 The smallest number in the array is 3 The average of the array elements is 53.6 The number of elements above average is 12 91 61 7 61 11 65 Make a folder named lab6_yourname containing the source code file, zip the folder and submit the zipped file to BrightSpace. Rubrics: Program: [2 marks] Presentation and Style: Readability, descriptive identifier, indentation, bracket placement, internal documentation (comments), use of appropriate constants [18 marks] Correctness: Program works without bugs

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Program import javautil public class ArrayDemo generate 20 random elements public static void initializeArrayint numbers Random r new Random int low 1 ... View full answer

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 Programming Questions!