Question: In Java: Read the following data from the user: Number of elements in the array The range in which the random numbers would be generated
In Java:
- Read the following data from the user:
- Number of elements in the array
- The range in which the random numbers would be generated
- Define and instantiate an array of integers, with the number of elements you read from user
- Fill in the array with integers in the range given by the user
- Write methods passing the array as argument, and returning the appropriate values, performing following tasks:
- Display the one dimensional array, with two spaces between values
- Calculate the average of numbers in the array
- Calculate the sum of odd values in the array
- Calculate the second maximum value in the array
- Build an array filled with the squares of the elements in a given array
- Count the number of peaks in the array. A peak is an element that has the value greater than the element before, and the element after.
- Run all methods for the array you created, and display the results in the main method of the program.
- If you implement all the required methods correctly, the program should generate outputs similar to the following:

Please enter the size of the array: 10 Enter the lower limit of the range for data: 1 Enter the upper limit of the range for data: 100 23 68 60 90 91 94 The original array is: 58 17 13 68 The average value in the array is: 58.2 The number of odd values in the array is: 4 The second maximum value in the array is: 91 The second maximum value in the array is: 2 The array containing squares of values in the original array is: 3364 289 169 529 4624 3600 4624 8100 8281 276447232 Press any key to continue
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
