Hello I am new in java. been working on it for 2months. I need to solve this by next week try going to youtube to learn but could not figure it out. Any help from the java community would be great.
Write a program to create an integer array of size 20. Then, the program should generate and insert random integers between 1 and 5, inclusive into the array. Next, the program should print the array as output.
A tremor is defined as a point of movement to and fro. To simulate it, the program will generate a random number between 0 and 19, which represents the location in the array (i.e. index number). Then, the 3 numbers to the left and right of this location should be reset to the value 0. If there isn’t 3 numbers to the left and right you may assume a lesser number depending on the boundaries of the array.
Then, the final array should be printed as output. There is no user input for this program.
Your program must include, at least, the following methods:
• insertNumbers, which will take as input one integer array and store the random numbers in it.
• createTremor, which will generate the random number as the location and return it.
A sample run of the program is shown below:
Sample output #1:
Array: 1 2 2 3 1 5 4 2 3 4 4 2 1 1 3 2 1 4 3 2 1
Random position: 5
Final Array: 1 2 0 0 0 5 0 0 0 4 4 2 1 1 3 2 1 4 3 2 1