PLEASE FOLLOW THE INSTRUCTION(I NEED C++ PROGRAM)Write a program that can be use
ID: 3842429 • Letter: P
Question
PLEASE FOLLOW THE INSTRUCTION(I NEED C++ PROGRAM)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 20 seats in each row.
Step 1: The program should have a FUNCTION that displays a screen that shows which seats are available and which are taken. Seats that are taken should be represented by a # symbol and seats that are available should be represented by a * symbol. The first thing your program should do is initialize all of the seats to available (*) and display the seating chart. ( The seating chart should be a two dimensional array.)
THE OUTPUT SHOULD BE LIKE THIS
Explanation / Answer
please find the below programme
#include <iostream>
#include <iomanip>
#include <string>
#include <istream>
#include <fstream>
using namespace std;
const int numberOfRow = 15;
const int numberOfCol = 20;
void print(char matrix[][20], int numberOfRow, int numberOfCol);
int main()
{
char matrix[numberOfRow][numberOfCol], seat[numberOfRow][numberOfCol];
char option;
int i, j;
int row,col;
int ticketsold = 0;
bool another =true;
for(i = 0; i < numberOfRow; i++)
for(j = 0; j < numberOfCol; j++)
matrix[i][j] = '*';
while(another)
{
print( matrix, numberOfRow, numberOfCol );
cout << " Menu: ";
cout << "1) Buy ticket ";
cout << "2) Total sell and exit ";
cout << "Enter your choice : ";
cin >> option;
cout << endl << endl;
switch (option)
{
case '1' :
{
cout << "Enter row: ";
cin >> row;
cout << " Enter seat: ";
cin >> col;
if( matrix[row][col] == '*')
{
matrix[row][col] = '#';
ticketsold++;
}
else
{
cout << "Invalid seat choice";
}
}
{
another=false;
}
default :
cout << "Invalid choice";*/
}
}
system("pause");
}
void print(char matrix[][20], int numberOfRow, int numberOfCol)
{
int row, col, i, j;
cout << "* Seats available ";
cout << "# Reserved Seats ";
cout << "Seats: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19" << endl;
for(i = 0; i < numberOfRow; i++)
{
cout << "Row" << setw(3) << i;
for(j=0; numberOfCol > j; j++)
cout << setw(3) << matrix[i][j];
cout << endl;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.