Question: Multi-Dimensional Array Processing Write a program in C++ language for a small theater to use to keep track of which seats have been reserved and

Multi-Dimensional Array Processing

Write a program in C++ language for a small theater to use to keep track of which seats have been reserved and which seats are available.

The program should begin by reading seating.txt, which contains information stored from the previous execution of the program, and displaying the seating chart to the screen so the user can see which seats are available and which are not. Use a 2D array to represent the theater seating with each row of the theater corresponding to each row of the array and each seat corresponding to a column in the array. The theater has thirty seats in a row and ten rows.

The first time the program is executed, seating.txt should be initialized to hold the price per seat on one line followed by all zeros for the seats with each value separated by a space. The program should then display the following where the first line is a header to help track the seat number and the numbers along the left are used to track the row number:

Multi-Dimensional Array Processing Write a

What you see below is not the data file. What is shown is example output produced by the program. The format of the data file is described in the text above.

Multi-Dimensional Array Processing Write a The output of your program should look exactly like this. Data values may differ.
 123456789012345678901234567890 1 000000000000000000000000000000 2 000000000000000000000000000000 3 000000000000000000000000000000 4 000000000000000000000000000000 5 000000000000000000000000000000 6 000000000000000000000000000000 7 000000000000000000000000000000 8 000000000000000000000000000000 9 000000000000000000000000000000 10 000000000000000000000000000000 

The program should then allow the user to choose from the following options.

Multi-Dimensional Array Processing Write a The output of your program should look exactly like this. Data values may differ.
1. Initialize seating for new performance. 2. View seating chart. 3. Reserve seats. 4. Calculate tickets remaining in row. 5. Calculate tickets remaining in theater. 6. Calculate total tickets sold. 7. Calculate ticket sales. 8. Exit program. 

The main function should interact with the user and call functions as needed; all input should be validated. There should be no file I/O within function main. The program should continue to execute until the user chooses to exit the program.

Whenever there has been a change to the seating chart, the program should display the updated seating chart.

Establish a global constant, ROWS, for the number of rows as well as a global constant, SEATS, for the number of seats in a row.

Include definitions for the following function prototypes you may also create additional "helper" functions if you wish, but you are required to include the functions described below:

void initializeSeating (int theater[][SEATS], double ticketPrice);

Prompts user for cost per ticket.

Initializes all elements in the 2D array to zero.

void displaySeating (const int theater[][SEATS]);

Displays seating chart to screen.

void readSeating (int theater[][SEATS], double ticketPrice);

Attempts to open the file containing the saved ticket price and seating chart.

If the file exists, the cost per ticket and seating information is read.

If the file does not exist, function initializeSeating is called.

void storeSeating (const int theater[][SEATS], double ticketPrice);

The contents of seating.txt is overwritten with the current data.

The first line of the file contains the ticket price.

The seating chart information is stored one row per line with a space between each seat.

int displayMenu (void);

Displays the user's options to the screen.

The user is prompted for a choice, which is returned from the function.

int calcTicketsAvailableInRow(const int theater[][SEATS], int row);

Calculates and returns the number of tickets available in the row.

The function performs no input or output.

NOTE: The value of row is expected to be a human-friendly row number, not an array index. You will need to take this into account!

int calcTotalTicketsSold(const int theater[][SEATS]);

Calculates and returns the total number of tickets that have been sold.

The function performs no input or output.

void reserveSeats(int theater[][SEATS]);

Prompts the user for the number of seats to be reserved; no more than SEATS may be reserved at a time.

If single seat reservation

Prompts the user for the preferred seat; input validation is employed.

If the preferred seat is available, the seat is reserved by replacing the value of zero with a value of one.

If a ticket for the seat has already been sold, the user is informed.

If multiple seat reservation

For simplicity, a multiple seat reservation will require all seats to be on the same row. No more than SEATS number of seats may be reserved at a time.

Prompts the user for the location of the first seat.

When validating input, consider the possibility that the first seat chosen will not allow for the requested number of seats (e. g. 10 seats are requested with a first seat number of 25).

If the requested number of seats beginning with the first seat selected are available, the seats are reserved by replacing the value of zero with a value of one in each element of the array representing the group of seats.

If any of the seats are not available, the user is informed and none of the seats are reserved.

Please give answer in C++ language.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!