Write a program to do the following. First, create an array of 10 elements of int type. Use a random number generator to generate the 10 elements. Each element is a random integer that is either 1, 2 or 3. Once these 10 random elements are generated, display them in the console window.
Next, examine the elements and modify them if necessary. Our goal is that no two consecutive elements are the same. In other words, every element must be different from the element right before it. For example, if both the 4th and the 5th elements are 2, change the 5th element to something else. The rules we use to modify the elements are as follows. If there are two consecutive elements of 1, change the second 1 to 2. If there are two consecutive elements of 2, change the second 2 to 3. If there are two consecutive elements of 3, change the second 3 to 1. After all the necessary changes are made, display all the 10 elements of the modified array.