+1 (315) 557-6473 

Create a Program to Implement Theater System in C++ Assignment Solution.


Instructions

Objective
Write a C++ assignment that involves creating a program to implement a theater system. In this assignment, you will need to design and code a C++ program that simulates a theater system. The program should be able to manage different aspects of the theater, such as booking seats, displaying available seats, calculating ticket prices, and handling customer transactions. This assignment will provide you with an opportunity to apply your C++ programming skills to real-world scenarios and enhance your understanding of object-oriented programming concepts.

Requirements and Specifications

CSC121 – Spring/2021
Project # 2
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 performane 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:
  1. Pre-conditions and post-conditions clearly stated for all functions.
  2. Thorough inline documentation for all code.
  3. No Global variables except for constants.
  4. Function prototypes for all programmer defined functions.
  5. Function main() will drive the application and will:
    1. Declare all necessary variables, including arrays
    2. Initialize the state of the Theater (all seats will initially be available)
    3. 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)
    4. 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.
    5. Execute until the user decides to exit the program.
  6. You must have individual functions for the following
  1. A function that populates an array with the prices read from the prices file specified by the user
  2. Displaying the Menu (see the test run). This function will display a menu from which the user can make selections.
  3. 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.
  4. A function that displays the current state of all of the seats in the theater (available or sold) (see the test run)
  5. A function that displays the prices of the seats in the theater. (see the test run)
  6. A function that displays the total sales of all tickets sold (see the test run)
  7. A function that handles ticket purchases and displays a summary of a purchase by a particular patron (See the test run)
  1. You should create stubs for any functions not completed or not working properly.
  2. Document any enhancements you might make beyond the basic requirements.
  3. Input validation – validate data as specified above
  4. 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.
  5. At a minimum, you must test your program using the below Test Run. You should also test for valid user input.

Academic Honesty: (Details regarding Academic Honesty Guidelines can be found in the College Catalog on page 49)

The College Catalog states: One of the missions of Camden County College is: "… preparing students to be continuous learners who succeed upon transfer, work effectively in the contemporary workplace and function as citizens and leaders in their community." The goal of course assignments is to ensure that students master the course material. Dishonesty in fulfilling any assignment undermines the learning process and the integrity of the college degree. All students are expected to do their own work. All forms of academic dishonesty are absolutely forbidden. Engaging in dishonest or unethical behavior may result in disciplinary action taken by the instructor, or other appropriate College official.

Lifting code from online sources is dishonest and a violation of the Academic Honesty Policy.

Among the consequences for violating the Academic Honesty Policy are failing the course and expulsion.

Students who violate the College’s Academic Honesty policy for Project # 2 will receive a grade of 0 for the project and be subject to failing the course.

Project Submission:

  1. Name your source file “yourlastnamefirstnameProject2.cpp”.
  2. You will need to complete your C++ assignment along with your file a Word document describing any aspects of the project that were not completed or are not working properly. List any functions that have been implemented as stubs. Also include in the document any enhancements that you made beyond the basic requirements. Name this file “yourlastnamefirstnamedescription”.
  3. Submit your project via the Project # 2 submission link in Canvas.
  4. Any of the requirements listed in the project requirements document that are missing or incomplete will result in a deduction to your grade. So make sure you read these requirements carefully. If you have questions about the requirements, make sure you contact me.
  5. The projects will be due at on 5/11/2021. Make note of the fact that the link for the project will close on 5/11. No submissions will be accepted after 11:59 pm on 5/11. Projects not submitted by the deadline will receive a grade of 0. Incomplete projects will receive consideration for partial credit, so make sure you submit whatever you have completed before the deadline.

In light of these facts, I strongly recommend that you complete the project and submit it before the due date. I will not be answering questions related to the project on 5/11, so get moving on this project asap.

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

C:\#Bill\MyVSProjects\CSC121Project2Spring2021\Debug\CSC121Project2Spring2021.exe (process 344) exited with code 0.

Press any key to close this window . . .

Source Code

#include

#include

#include

#include

#include

using namespace std;

const int MAX_ROWS = 15;

const int MAX_COLS = 10;

const char AVAILABLE = 'A';

const char SOLD = 'S';

// Let the user enter a key then presses enter

void pause()

{

cout << "Press c to continue and then press return: ";

char c;

cin >> c;

cout << endl;

}

// Load the prices from a file

void loadSeatingPrices(double seatingPrices[MAX_ROWS])

{

// Get a valid performance number

cout << "Select your performance (1, 2, or 3): ";

int performance;

cin >> performance;

while (performance < 1 || performance > 3)

{

cout << "Invalid entry - Select your performance (1, 2, or 3): ";

cin >> performance;

}

// Load the prices from file

stringstream ss;

ss << "prices" << performance << ".txt";

string filename = ss.str();

// Open the file

ifstream inFile(filename.c_str());

if (!inFile.is_open())

{

cout << "Error: failed to open " << filename << endl;

exit(0);

}

cout << endl;

cout << "Loading Prices for performance" << endl;

cout << endl;

// Put the prices into the array

int rowNumber;

double price;

while (inFile >> rowNumber >> price)

seatingPrices[rowNumber - 1] = price;

inFile.close();

}

// Print the table of prices

void viewSeatingPrices(const double rowPrices[MAX_ROWS])

{

cout << "Ticket Prices By Row" << endl;

cout << setw(10) << right << "Row" << setw(10) << right << "Price" << endl;

cout << setw(10) << right << "---" << setw(10) << right << "-----" << endl;

for (int row = 0; row < MAX_ROWS; row++)

cout << setw(10) << right << (row + 1) << setw(10) << right << fixed << setprecision(2) << rowPrices[row] << endl;

pause();

}

// Make all seats empty

void initializeSeats(char seats[MAX_ROWS][MAX_COLS])

{

for (int row = 0; row < MAX_ROWS; row++)

for (int col = 0; col < MAX_COLS; col++)

seats[row][col] = AVAILABLE;

}

// Print out all the seats

void viewSeats(const char seats[MAX_ROWS][MAX_COLS])

{

cout << setw(15) << right << "Seats" << endl;

// Print column labels

cout << setw(8) << "";

for (int col = 0; col < MAX_COLS; col++)

cout << (col + 1);

cout << endl;

// Print each row

for (int row = 0; row < MAX_ROWS; row++)

{

cout << "Row" << setw(3) << right << (row + 1) << " ";

for (int col = 0; col < MAX_COLS; col++)

cout << seats[row][col];

cout << endl;

}

cout << endl;

cout << setw(8) << "" << "Legend: S = Sold" << endl;

cout << setw(8) << "" << " A = Available" << endl;

pause();

}

// Purchase a ticket

double purchaseTicket(const double seatingPrices[MAX_ROWS], char seats[MAX_ROWS][MAX_COLS])

{

// Print out the seats if the user wishes to

cout << " C++ Theatre" << endl;

cout << " Ticket Purchase Opportunity" << endl;

cout << "Do you wish to view the chart of available seats before making your selections (y/n)? ";

char response;

cin >> response;

if (response == 'y' || response == 'Y')

viewSeats(seats);

// Ask for the desired seat to purchase

char again = 'Y';

int numTickets = 0;

double totalCost = 0;

while (again == 'Y' || again == 'y')

{

cout << "Please enter desired row number (1-15): ";

int row;

cin >> row;

cout << "Please enter desired seat number (1-10): ";

int col;

cin >> col;

row--;

col--;

// Check if within range

if (row < 0 || row >= MAX_ROWS || col < 0 || col >= MAX_COLS)

{

cout << "Error: Invalid seat location." << endl;

}

else if (seats[row][col] == SOLD)

{

// Check that it is available

cout << "Sorry. That seat has been sold." << endl;

}

else

{

// Purchase if available

seats[row][col] = SOLD;

cout << "Purchase confirmed" << endl;

numTickets++;

totalCost += seatingPrices[row];

}

// Ask if interested for another purchase

cout << "Would you like to purchase another seat (y/n)? ";

cin >> again;

}

cout << endl;

cout << "You have purchased a total of " << numTickets << " for a total price of $" << fixed << setprecision(2) << totalCost << endl;

return totalCost;

}

// Entry point of the program

int main()

{

// Start by loading the prices from file

double seatingPrices[MAX_ROWS];

loadSeatingPrices(seatingPrices);

viewSeatingPrices(seatingPrices);

// Initialize the empty seats

char seats[MAX_ROWS][MAX_COLS];

initializeSeats(seats);

double totalSales = 0;

bool quit = false;

while (!quit)

{

// Ask the user what to do

cout << " CSC121 Theatre" << endl;

cout << "1. View Available Seats" << endl;

cout << "2. View Seating Prices" << endl;

cout << "3. View Ticket Sales" << endl;

cout << "4. Purchase a Ticket" << endl;

cout << "5. Exit the Program" << endl;

cout << "Enter your choice (1-5): ";

int choice;

cin >> choice;

cout << endl;

// Execute user's choice

switch (choice)

{

case 1:

viewSeats(seats);

break;

case 2:

viewSeatingPrices(seatingPrices);

break;

case 3:

cout << "Total Sales to Date: $" << fixed << setprecision(2) << totalSales << endl;

break;

case 4:

totalSales += purchaseTicket(seatingPrices, seats);

reak;

case 5:

quit = true;

break;

default:

cout << "Choice must be between 1 and 5." << endl;

}

cout << endl;

}

return 0;

}