Question: Using java and arrays Design a program that will simulate how theater seats may fill as people walk into the theater. The program should maximize
Design a program that will simulate how theater seats may fill as people walk into the theater. The program should maximize the distance between each person by trying to find a seat in the middle of the longest sequence of unoccupied seats. For example, consider the situation where ten seats are empty. _ _ _ _ _ _ _ _ _ The first person will occupy a middle position: _____X_____ The next person will be in the middle of the empty area at the left (left has more seats). -X-X_ __ _ The next person will be in the section to the right: _ _X-X-X_ _ The rest of the diagram should fill in as follows: _XX-X-X_ _XX_XX-X_ _XX_XX_XX_ xxx_xx_xx_ xxxxxx_xx_ xxxxxxxxx_ _ XXXXXXXXXX Write a program that asks the user for the number of seats and then prints out diagrams (one diagram per line) in the format give above each time a new person occupies a seat. In the above example, you would print a total of 11 diagrams (one per line), the empty diagram and then 10 additional diagrams
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
