Answer:
The codes (written in Java) that implement the logic as described in the question are presented below:
Explanation:
An integer array with a specific size 12 is declared and named as a (Line 7).
Since the variable k is expected to hold a value between 0 and 6, one way to achieve the aim is to randomly generate an integer between 0 to 6 and then assign it to the variable k. We can create a random integer within a specific range using Java Random Generator. The steps are as follows: