Hi can anyone help me fix my code, i keep on getting erros and option 4 for my main menu will not work.
Problem asks:
Write a program that can be used by a small theater to sell tickets for performances. The theater’s auditorium has 15 rows of seats, with 30 seats in each row. The program should display a screen that shows which seats are available and which are taken. For example, the following screen shows a chart depicting each seat in the theater. 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 seat prices for each row. The prices can be stored in a separate array. (Suppose the seats in the same row have the same price)
- Once the prices are entered, the program should display a seating chart similar to the one shown above.( The prices should be the values the user entered)
- The user may enter the row and seat numbers for tickets being sold. Every time a ticket or group of tickets is purchased, the program should display the total ticket prices and update the seating chart.
- The program should give the user an option to see a list of how many seats have been sold, how many seats are available in each row, and how many seats are available in the entire auditorium.
Input Validation: When tickets are being sold, do not accept row or seat numbers that
do not exist. When someone requests a particular seat, the program should make sure
that seat is available before it is sold.
Here is my code:
//Function Declarations
int menu (); //To show main menu
void seating_Chart (); //To show seating chart
const char FULL = '*'; //Seat taken
const char EMPTY = '#'; //Seat open
const int rows = 15; //Number of rows
const int columns = 30; //Number of seats per row
char map [rows][columns]; //Array to hold seating chart
double price;
int total = 0;
int seat = 450;
int seat2 = 0;
int Quit = 1;
int main ()
{
const int Num_Rows = 15;
int price [Num_Rows];
int row2, column2, cost;
int answer;
for (int a = 0; a < rows; a++)
{
cout << "Please enter the price for row " << (a + 1) << ":";
cin >> price [a];
}
for (int b = 0; b < rows; b++)
{
for (int c = 0; c < columns; c++)
map [b][c] = EMPTY;
}
int choice;
do
{
choice = menu(); // Shows the main menu function.
switch (choice)
{
case 1:
cout << "View Prices\n";
for (int i = 0; i < rows; i++)
{
cout << "The price for row " << (i + 1) << " is: ";
cout << price [i] << endl;
}
break;
case 2:
cout << "Buy a Ticket\n";
do
{
cout << "Please select the row you would like to sit in: ";
cin >> row2;
cout << "Please select the seat you would like to sit in: ";
cin >> column2;
if (map [row2] [column2] == '*')
{
cout << "Sorry that seat is sold-out, Please pick a new seat.";
cout << endl;
}
else
{
cost = price [row2] + 0;
total = total + cost;
cout << "The ticket costs: " << cost << endl;
cout << "Confirm Purchase? Enter (1 = YES / 2 = NO)";
cin >> answer;
seat = seat - answer;
seat2 += answer;
if (answer == 1)
{
cout << "Your purchase has been confirmed." << endl;
map [row2][column2] = FULL;
}
else if (answer == 2)
{
cout << "Would you like to look at another seat? (1 = YES / 2 = NO)";
cout << endl;
cin >> Quit;
}
while (Quit == 1);
break;
case 3:
cout << "View Available Seats\n";
seating_Chart ();
break;
case 4:
cout << "View Ticket Sales\n";
break;
case 5:
cout << "Exit\n";
}
}
while (choice != 5);
return 0;
}
int menu()
{
int menChoice;
cout << endl << endl;
cout << " MAIN MENU\n";
cout << " 1) View Prices.\n";
cout << " 2) Buy a Ticket.\n";
cout << " 3) View Available Seats.\n";
cout << " 4) View Ticket Sales.\n";
cout << " 5) Exit.\n";
cout << "Please enter your choice: ";
cin >> menChoice;
cout << endl << endl;
return menChoice;
}
void seating_Chart ()
{
cout << "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30\n";
for (int count = 0; count < 15; count++)
{
cout << endl << "Row " << (count + 1);
for (int count2 = 0; count2 < 30; count2++)
{
cout << " " << map [count] [count2];
}
}
cout << endl;
}
}