The following Theater Seating Program from page 311 of your textbook is shown below:
Please write the program described above, assuming that the user will enter a row and seat which start at 1 and where row 1 is the bottom front row, and seat 1 is the leftmost seat. Make sure to write at least one method in addition to main. Following is sample output:
[cpersiko@fog cs111a]$ java SeatingChart 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 20 20 20 20 20 20 10 10 10 10 20 20 20 20 20 20 10 10 10 10 20 20 20 20 20 20 10 10 20 20 30 30 40 40 30 30 20 20 20 30 30 40 50 50 40 30 30 20 30 40 50 50 50 50 50 50 40 30 Pick by (s)eat or (p)rice or (q) to quit: s Enter the row and seat number you want: 2 2 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 20 20 20 20 20 20 10 10 10 10 20 20 20 20 20 20 10 10 10 10 20 20 20 20 20 20 10 10 20 20 30 30 40 40 30 30 20 20 20 0 30 40 50 50 40 30 30 20 30 40 50 50 50 50 50 50 40 30 Pick by (s)eat or (p)rice or (q) to quit: s Enter the row and seat number you want: 1 8 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 20 20 20 20 20 20 10 10 10 10 20 20 20 20 20 20 10 10 10 10 20 20 20 20 20 20 10 10 20 20 30 30 40 40 30 30 20 20 20 0 30 40 50 50 40 30 30 20 30 40 50 50 50 50 50 0 40 30 Pick by (s)eat or (p)rice or (q) to quit: p What price do you want to buy? 10 0 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 20 20 20 20 20 20 10 10 10 10 20 20 20 20 20 20 10 10 10 10 20 20 20 20 20 20 10 10 20 20 30 30 40 40 30 30 20 20 20 0 30 40 50 50 40 30 30 20 30 40 50 50 50 50 50 0 40 30 Pick by (s)eat or (p)rice or (q) to quit: p What price do you want to buy? 20 0 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 0 20 20 20 20 20 10 10 10 10 20 20 20 20 20 20 10 10 10 10 20 20 20 20 20 20 10 10 20 20 30 30 40 40 30 30 20 20 20 0 30 40 50 50 40 30 30 20 30 40 50 50 50 50 50 0 40 30 Pick by (s)eat or (p)rice or (q) to quit: s Enter the row and seat number you want: 2 2 Sorry, seat already occupied. 0 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 0 20 20 20 20 20 10 10 10 10 20 20 20 20 20 20 10 10 10 10 20 20 20 20 20 20 10 10 20 20 30 30 40 40 30 30 20 20 20 0 30 40 50 50 40 30 30 20 30 40 50 50 50 50 50 0 40 30 Pick by (s)eat or (p)rice or (q) to quit: s Enter the row and seat number you want: 20 40 Sorry, invalid row. 0 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 0 20 20 20 20 20 10 10 10 10 20 20 20 20 20 20 10 10 10 10 20 20 20 20 20 20 10 10 20 20 30 30 40 40 30 30 20 20 20 0 30 40 50 50 40 30 30 20 30 40 50 50 50 50 50 0 40 30 Pick by (s)eat or (p)rice or (q) to quit: p What price do you want to buy? 5 Sorry, no seat found with that price. 0 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 0 20 20 20 20 20 10 10 10 10 20 20 20 20 20 20 10 10 10 10 20 20 20 20 20 20 10 10 20 20 30 30 40 40 30 30 20 20 20 0 30 40 50 50 40 30 30 20 30 40 50 50 50 50 50 0 40 30 Pick by (s)eat or (p)rice or (q) to quit: q [cpersiko@fog cs111a]$You can use the following code to initialize your two-dimensional array of seat prices:
int[][] seats = { { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }, { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }, { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }, { 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 }, { 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 }, { 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 }, { 20, 20, 30, 30, 40, 40, 30, 30, 20, 20 }, { 20, 30, 30, 40, 50, 50, 40, 30, 30, 20 }, { 30, 40, 50, 50, 50, 50, 50, 50, 40, 30 } };