This project promotes the following Student Learning Outcomes:

  • Develop and implement algorithms through the process of top-down, stepwise refinement
  • Design and develop programs that use functions to input data from the standard input stream and output data to the standard output stream
  • Implement programming solutions which use selection, repetition, and sequential control structures where appropriate
  • Demonstrate through program development the use of the various arithmetic, assignment and logical operators
  • Construct modular programs using functions that pass arguments both by value and by reference
  • Write programs demonstrating the use of one-and two-dimensional arrays and strings

Problem Statement

Write a program to assign seating for performances at a small theater. The theater has 15 rows with 10 seats in each row. The program will need to display a screen that shows all 150 seats. Seats that are available will be represented by 'A'. Seats that are sold will be represented by S.

There are 3 performances scheduled for a particular show. The program will begin by prompting the user for the performance number (1, 2, 3). There are 3 files which contain the current pricing for the specified performance. If the user enters '1', then a file named prices1.txt will be used to show the current theater seating prices for performance # 1. If the user enters 2, then a file named prices2.txt will be used to show the current theater seating prices for performance # 2. If the user enters 3, then a file named prices3.txt will be used to show the current theater prices for performance # 3. If the user enters any other character a message will be displayed "Invalid entry - Select your performance (1, 2, or 3):", and allow the user to re-enter the performance number. Do not alter the prices text files that I have provided.

In addition to those situations displayed below in the test run, do not accept row or seat numbers that do not exist. Do not accept seats that have been sold.

Your program must contain the following items:

  • Pre-conditions and post-conditions clearly stated for all functions.
  • Thorough inline documentation for all code.
  • No Global variables except for constants.
  • Function prototypes for all programmer defined functions.
  • Function main() will drive the application and will:
    • Declare all necessary variables, including arrays
    • Initialize the state of the Theater (all seats will initially be available)
    • Allow the user to Select the performance number to determine which prices file to use for pricing. (Note that seat prices will vary depending on the performance selected)
    • Invoke user defined functions as necessary. Some functions may be void, some may return values. Functions will have parameters. Some will be value parameters some may be reference parameters.
    • Execute until the user decides to exit the program.
  • You must have individual functions for the following
    • A function that populates an array with the prices read from the prices file specified by the user
    • Displaying the Menu (see the test run). This function will display a menu from which the user can make selections.
    • A function that gets the users choice of menu option and returns that choice as an int. The user will be prompted to enter a selection.
    • A function that displays the current state of all of the seats in the theater (available or sold) (see the test run)
    • A function that displays the prices of the seats in the theater. (see the test run)
    • A function that displays the total sales of all tickets sold (see the test run)
    • A function that handles ticket purchases and displays a summary of a purchase by a particular patron (See the test run)
  • You should create stubs for any functions not completed or not working properly.
  • Document any enhancements you might make beyond the basic requirements.
  • Input validation - validate data as specified above
  • Your functions must be cohesive. They should focus on doing a single thing. Most functions that you create should be between 5 and 15 lines. Anything longer probably needs to be decomposed into additional functions.
  • At a minimum, you must test your program using the below Test Run. You should also test for valid user input.

Test Run

Select your performance (1, 2, or 3): 4
Invalid entry - Select your performance (1, 2, or 3): 3

Loading Prices for performance

Ticket Prices By Row
Row Price
--- -----
1 40.00
2 40.00
3 40.00
4 40.00
5 40.00
6 30.00
7 30.00
8 30.00
9 30.00
10 30.00
11 20.00
12 20.00
13 20.00
14 20.00
15 20.00
Press c to continue and then press return: c

CSC121 Theatre

1. View Available Seats
2. View Seating Prices
3. View Ticket Sales
4. Purchase a Ticket
5. Exit the Program


Enter your choice(1-5): 1

Seats
12345678910

Row 1 AAAAAAAAAA
Row 2 AAAAAAAAAA
Row 3 AAAAAAAAAA
Row 4 AAAAAAAAAA
Row 5 AAAAAAAAAA
Row 6 AAAAAAAAAA
Row 7 AAAAAAAAAA
Row 8 AAAAAAAAAA
Row 9 AAAAAAAAAA
Row 10 AAAAAAAAAA
Row 11 AAAAAAAAAA
Row 12 AAAAAAAAAA
Row 13 AAAAAAAAAA
Row 14 AAAAAAAAAA
Row 15 AAAAAAAAAA


Legend: S = Sold
A = Available
Press c to continue and then press return: c

CSC121 Theatre

1. View Available Seats
2. View Seating Prices
3. View Ticket Sales
4. Purchase a Ticket
5. Exit the Program


Enter your choice(1-5): 4

C++ Theatre
Ticket Purchase Opportunity
Do you wish to view the chart of available seats
before making your selections (y/n)? n

Please enter desired row number (1-15): 1

Please enter desired seat number (1-10): 1

Purchase confirmed

Would you like to purchase another seat (y/n)? y

Please enter desired row number (1-15): 1

Please enter desired seat number (1-10): 2

Purchase confirmed

Would you like to purchase another seat (y/n)? Y

Please enter desired row number (1-15): 12

Please enter desired seat number (1-10): 10

Purchase confirmed

Please enter desired row number (1-15): 1

Please enter desired seat number (1-10): 2

Sorry. That seat has been sold.

Would you like to purchase another seat (y/n)? Y

Please enter desired row number (1-15): 12

Please enter desired seat number (1-10): 9

Purchase confirmed

Would you like to purchase another seat (y/n)? n


You have purchased a total of 4 tickets for a total price of $120.00
CSC121 Theatre

1. View Available Seats
2. View Seating Prices
3. View Ticket Sales
4. Purchase a Ticket
5. Exit the Program


Enter your choice(1-5): 1


Seats
12345678910

Row 1 SSAAAAAAAA
Row 2 AAAAAAAAAA
Row 3 AAAAAAAAAA
Row 4 AAAAAAAAAA
Row 5 AAAAAAAAAA
Row 6 AAAAAAAAAA
Row 7 AAAAAAAAAA
Row 8 AAAAAAAAAA
Row 9 AAAAAAAAAA
Row 10 AAAAAAAAAA
Row 11 AAAAAAAAAA
Row 12 AAAAAAAASS
Row 13 AAAAAAAAAA
Row 14 AAAAAAAAAA
Row 15 AAAAAAAAAA


Legend: S = Sold
A = Available
Press c to continue and then press return: c


CSC121 Theatre

1. View Available Seats
2. View Seating Prices
3. View Ticket Sales
4. Purchase a Ticket
5. Exit the Program


Enter your choice(1-5): 4

C++ Theatre
Ticket Purchase Opportunity
Do you wish to view the chart of available seats
before making your selections (y/n)? n

Please enter desired row number (1-15): 10

Please enter desired seat number (1-10): 4

Purchase confirmed

Would you like to purchase another seat (y/n)? y

Please enter desired row number (1-15): 10

Please enter desired seat number (1-10): 5

Purchase confirmed

Would you like to purchase another seat (y/n)? n


You have purchased a total of 2 tickets for a total price of $60.00
CSC121 Theatre

1. View Available Seats
2. View Seating Prices
3. View Ticket Sales
4. Purchase a Ticket
5. Exit the Program


Enter your choice(1-5): 1

Seats
12345678910

Row 1 SSAAAAAAAA
Row 2 AAAAAAAAAA
Row 3 AAAAAAAAAA
Row 4 AAAAAAAAAA
Row 5 AAAAAAAAAA
Row 6 AAAAAAAAAA
Row 7 AAAAAAAAAA
Row 8 AAAAAAAAAA
Row 9 AAAAAAAAAA
Row 10 AAASSAAAAA
Row 11 AAAAAAAAAA
Row 12 AAAAAAAASS
Row 13 AAAAAAAAAA
Row 14 AAAAAAAAAA
Row 15 AAAAAAAAAA


Legend: S = Sold
A = Available
Press c to continue and then press return: c

CSC121 Theatre

1. View Available Seats
2. View Seating Prices
3. View Ticket Sales
4. Purchase a Ticket
5. Exit the Program


Enter your choice(1-5): 3


Total Sales to Date: $180.00


CSC121 Theatre

1. View Available Seats
2. View Seating Prices
3. View Ticket Sales
4. Purchase a Ticket
5. Exit the Program


Enter your choice(1-5): 7
Choice must be between 1 and 5. Please re-enter: 5
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.