Java Programming Write a program that does the following: - reads three integers from the `args` array (in this order): the rule number, the number of iterations and the width of the automaton to...


Java Programming


Write a program that does the following:
- reads three integers from the `args` array (in this order): the rule number, the number of iterations and the width of the automaton to display
- prints the state of a Rule N automaton of the given width for the given number of iterations
- the starting state of the automaton should have one 'on' cell in the center (if the width is even, start with the cell to the right of the center line turned on)
- if a cell is on the edge of the array, consider its left/right neighbor always 'off'
- use X to indicate an 'on' cell and O to indicate an 'off' cell
- if the number of iterations is 0, you should write the starting state


### Sample executions


Input: `110 10 20`


Output:


```
OOOOOOOOOOXOOOOOOOOO
OOOOOOOOOXXOOOOOOOOO
OOOOOOOOXXXOOOOOOOOO
OOOOOOOXXOXOOOOOOOOO
OOOOOOXXXXXOOOOOOOOO
OOOOOXXOOOXOOOOOOOOO
OOOOXXXOOXXOOOOOOOOO
OOOXXOXOXXXOOOOOOOOO
OOXXXXXXXOXOOOOOOOOO
OXXOOOOOXXXOOOOOOOOO
```


Input: `110 0 20`


Output:


```
OOOOOOOOOOXOOOOOOOOO
```



Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here