Reference no: EM132200877
Write a JAVA program called Counter that will do the following:
Program will ask the user to enter the size of an array.
It will create an integer array based on the size user entered.
It will fill the array with random numbers in the range from 0 to 9.
It will display the array contents.
It will display how many of the consecutive elements were repeated. (pairs of numbers)
You should write the program in a modular way:
Random filling of the array should be done in a separate method.
Counting the repeated elements should also be done in a separate method.
Sample output 1:
Enter the size of the array
20
The array elements generated are
6 9 6 5 6 4 0 3 8 8 8 1 7 4 6 8 8 2 2 6
There are 4 numbers that are repeated consecutively
Sample output 2:
Enter the size of the array
18
The array elements generated are
1 0 1 3 7 0 0 4 4 3 3 4 5 7 3 7 3 0
There are 3 numbers that are repeated consecutively