Using the following implementation design, write a program that can be used by a small venue to manage which seats have been reserved for a performance. The venue has 15 rows of seats with 30 seats in each row. When requested, the program should display a screen that shows which seats are available and which are taken. For example, the following image shows a chart depicting each seat in a venue. Seats that are taken are represented by an * symbol, and seats that are available are represented by a # symbol.
When the program begins, it should ask the user to enter the name of a text file containing the current seating chart. The file will consist of 15 lines with 30 characters (* or #) on each line separated by spaces. The program should read the contents of the file to initialize its seating chart. You may use the following file as a seating chart for your program: venuSeating.txt.
The program should provide the following options to the user:
When the user wants to reserve a seat, the program should display the current seating chart and then prompt the user for how many seats he wants to reserve. The program will then prompt the user N times to enter the row and seat number for the seat he wants to reserve and update the seating chart.
The show statistics option displays important statistics to the user about the venue's current reservations. It should display how many seats have been reserved, how many seats are available in the entire venue and how many seats are available in each row.
When the user selects to quit the program, the program should save the current state of its seating chart in the same text file from which it originally read the seating chart from.
Input validation:
Additional Assignment Requirements and Notes
Sample Output
Enter reservations state file name: venuSeating.txt
1. Reserve Seats
2. View Seating Chart
3. Show Statistics
4. Quit
Choice: 1
Seats
0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3
1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
Row 1 * * * # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 2 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 3 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 4 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 5 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 6 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 7 # # # # # # # # # # # # # # * # # # # # # # # # # # # # # #
Row 8 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 9 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 10 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 11 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 12 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 13 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 14 * # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 15 # # # # # # # # # # # # # # # # # # # * # # # # # # # # # *
How many seats do you want to reserve? 2
Enter row # and seat # of the seat to reserve: 3 1
Enter row # and seat # of the seat to reserve: 3 2
1. Reserve Seats
2. View Seating Chart
3. Show Statistics
4. Quit
Choice: 2
Seats
0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3
1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
Row 1 * * * # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 2 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 3 * * # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 4 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 5 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 6 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 7 # # # # # # # # # # # # # # * # # # # # # # # # # # # # # #
Row 8 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 9 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 10 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 11 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 12 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 13 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 14 * # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Row 15 # # # # # # # # # # # # # # # # # # # * # # # # # # # # # *
1. Reserve Seats
2. View Seating Chart
3. Show Statistics
4. Quit
Choice: 3
Total Seats Reserved: 9
Total Seats Available: 441
Number of Seats Available by row:
Row 1: 27
Row 2: 30
Row 3: 28
Row 4: 30
Row 5: 30
Row 6: 30
Row 7: 29
Row 8: 30
Row 9: 30
Row 10: 30
Row 11: 30
Row 12: 30
Row 13: 30
Row 14: 29
Row 15: 28
1. Reserve Seats
2. View Seating Chart
3. Show Statistics
4. Quit
Choice:
This program manages the reservation of seats for a small venue's auditorium. The auditorium has 15 rows of 30 seats each.
The program presents the user the following menu options:
The program maintains the set of reserved seats within a text file between program runs. The program asks the user for the name of the text file when it is first run, it reads the data from the file, and then writes data back to the file when the user selects quit from the menu.
Figure: see image.
Name | Type | Description |
N_ROWS | Int | Constant representing the number of rows in the auditorium. Default is 15. |
N_SEATS | Int | Constant representing the number of seats in each row of the auditorium. Default is 30. |
SEAT_AVAILABLE | Char | Character indicating that a particular seat is available. Default is: '#' |
SEAT_RESERVED | Char | Character indicating that a particular seat is reserved. Default is: '*' |
MENU_CHOICE_RESERVE | Int | Constant representing "reserve seat" menu option. Default is 1. |
MENU_CHOICE_DISPLAY | Int | Constant representing "view seating chart" menu option. Default is 2. |
MENU_CHOICE_SHOW_STATS | Int | Constant representing "show statistics" menu option. Default is 3. |
MENU_CHOICE_QUIT | Int | Constant representing "quit" menu option. Default is 3. |
None.
Function main
This function manages the seat reservation for a small venue's auditorium.
Parameters
Name | Type | Direction (in/out) | Description |
None. |
Pseudo Code
Function loadReservationState
This function opens the specified file and reads its contents into the provided array.
Parameters
Name | Type | Direction (in/out) | Description |
stateFileName | string | In | Name of the containing reservation state. |
reservations | char[][] | In/Out | 2-dimensional array to hold the seat reservation status |
Pseudo Code
Function saveReservationState
This function opens the specified file and writes the contents of the reservations array to the file.
Parameters
Name | Type | Direction (in/out) | Description |
stateFileName | string | In | Name of the file containing reservation state. |
reservations | char[][] | In | 2-dimensional array containing the reservation seat status |
Pseudo Code
Function getMenuChoice
This function displays the menu and returns the user's choice - MENU_CHOICE_XXX
Parameters
Name | Type | Direction (in/out) | Description |
None. |
Pseudo Code
Function processChoice
This function invokes the appropriate function based on the user's choice.
Parameters
Name | Type | Direction (in/out) | Description |
choice | Int | In | User's menu choice |
reservations | char[][] | In/out | 2-dimensional array to hold the seat reservation status |
Pseudo Code
Function makeReservation
This function asks the user which seat(s) he wants to reserve and updates the status of the seats in the reservations array.
Parameters
Name | Type | Direction (in/out) | Description |
reservations | char[][] | In/out | 2-dimensional array to hold the seat reservation status |
Pseudo Code
Function getSeat
This function prompts the user for a row number and seat number.
Parameters
Name | Type | Direction (in/out) | Description |
row | Int | In/out | Row number that is entered by the user. |
Seat | Int | In/out | Seat number that is entered by the user |
Pseudo Code
Function displayReservationState
This function displays the contents of the reservations array to the user. The output is similar to the following: see image.
Parameters
Name | Type | Direction (in/out) | Description |
reservations | char[][] | In | 2-dimensional array to hold the seat reservation status |
Pseudo Code
Function calculateReservationStatistics
This function displays the following statistics about the venue's current reservations.
Parameters
Name | Type | Direction (in/out) | Description |
reservations | char[][] | In | 2-dimensional array to hold the seat reservation status |
Pseudo Code