Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A theater seating chart is implemented as a two- dimensional array of ticket pri

ID: 3757800 • Letter: A

Question

A theater seating chart is implemented as a two- dimensional array of ticket prices, like this:

3 6 7 9

10 11 12 13

14 15 16 17

19 21 23 25

The price of the seat number 1 is $3. The price of the seat number 2 is $6. ... The price of the seat number 5 is $10 ... The price of the seat number 16 is $25

Write a program that prompts users to pick either a seat or a price.

Mark sold seats by changing the price to 0. When a user specifies a seat, make sure it is available.

You will display a message "Sorry, the seat is not available."

When a user specifies a price, find any seat with that price.

The seat number is identifed using the row and column.

For example, if row is 0 and column is 0, the seat is $3.

Again, if row is 1 and column is 2, then the seat is $12.

A sample run will be:

The original seat chart is

3 6 7 9

10 11 12 13

14 15 16 17

19 21 23 25

What price do you want? $100
Sorry, it is not available.

What seat do you want (row and column)? 9 9

Sorry, it is not available.

What price do you want? $9

What seat do you want (row and column)? 1 2

What price do you want? $23

What seat do you want? 3 2

The final seat char is

3 6 7 0

10 11 0 13

14 15 0 17

19 21 0 25

Explanation / Answer

import java.util.*; public class Theater { static Scanner in = new Scanner(System.in); static int[][] seatingChart; public static void main(String[] args) { seatingChart = new int[][] { { 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 }, }; System.out.println("Welcome to the Box Office Program."); //Introduction Statements System.out.println("Please note that seats are arranged such that"); System.out.println("row 1, column 1, is the bottom front row."); System.out.println("Also, a zero denotes the seat is already sold."); printSeats(seatingChart); char response = 'Y'; while ((response == 'Y') || (response == 'y')) { System.out.print("Pick by Seat , Price

, or Quit : "); char choice = in.next().charAt(0); switch (choice) { case'S':case's': { sellSeatByNumber(seatingChart); break; } case'P':case'p': { sellSeatByPrice(seatingChart); break; } case'Q':case'q': { System.out.print("Thank you, come again!"); System.exit(0); } default: { System.out.println("Error: Invalid choice."); } } System.out.print("Would you like to reserve another seat (Y/N)?: "); response = in.next().charAt(0); } System.out.print("Thank you, come again!"); } public static void printSeats(int seatingChart[][]) { for(int i=0; i

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote