Write a program that: Prompts the user to enter the number of cells C. Declares
ID: 3939235 • Letter: W
Question
Write a program that:
Prompts the user to enter the number of cells C.
Declares an integer array cell[] with C elements.
Prompts the user to enter the number of time steps N.
Prompts the user to enter the list of indices of cells that contain 1
(enter negative index to nish).
Print a “ruler” line with C digits, 0 through 9, repeated
(see sample output below for clari cation).
Run the cellular automaton for N time steps, using the rules de ned above. On each time step, display the cells on one line,
printing a ‘#’ if the cell contains a 1, or a space if the cell contains a 0.
Your program's output should match the sample runs
public static void main(String[] args){
}
The data[] array contains data.length cells, with each cell containing either 1 or 0. displayCells() prints each cell of the data[] array on the same line, displaying a ‘#’ if the cell contains a 1, a space if the cell contains a 0.
The data[] array contains data.length cells, either 1 or 0. updateCells() updates each cell in the data[] array, according to the rules de ned earlier in this handout, for one step. (Hint: you will need to create a temporary array in updateCells(), make the updates into the temporary array, and copy the temporary array to the data[] array before the method returns.)