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:

  1. Read the following data from the user:
    • Number of elements in the array
    • The range in which the random numbers would be generated
  2. Define and instantiate an array of integers, with the number of elements you read from user
  3. Fill in the array with integers in the range given by the user
  4. 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.
  5. Run all methods for the array you created, and display the results in the main method of the program.
  6. If you implement all the required methods correctly, the program should generate outputs similar to the following:

In Java: Read the following data from the user: Number of elements

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

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!