Answer:
See explaination
Explanation:
#include<iostream>
using namespace std;
char seating[15][20];
float row_price[15];
//This function will display the seating chart
void display()
{
cout<<"-------------------------- Seating Chart----------------------------\n";
cout<<"Seats: ";
for(int i=0;i<20;i++)
cout<<i<<" ";
cout<<"\n";
for(int i=0;i<15;i++)
{
if(i<10)
cout<<"Row "<<i<<" ";
else
cout<<"Row "<<i<<" ";
for(int j=0;j<20;j++)
{
if(j<10)
cout<<seating[i][j]<<" ";
else
cout<<seating[i][j]<<" ";
}
cout<<"\n";
}
}
//This function will prompt to the user to enter row fares
void row_price_details()
{
cout<<"Enter row wise fares:\n";
for(int i=0;i<15;i++)
cin>>row_price[i];
}
//Main function
int main()
{
char choice;
int i,j,row,seat;
float revenue=0;
//step-1 initializing seating chart with * (available)
for(i=0;i<15;i++)
{
for(j=0;j<20;j++)
{
seating[i][j]='*';
}
}
//displaying seating chart by calling display() function
display();
//prompt the user to enter row fares by calling row_price_details() function
row_price_details();
//Booking seats until user say n or N
do{
cout<<"Enter Row number and Seat number:\n";
cin>>row>>seat;//getting seat and row numbers
//validating enter seat number or row number or with in boundry or not
//if not displays Error message
if(row<15||seat<<20)
{
//checking entered position is available or not
//if not displays sorry message
if(seating[row][seat]=='*')
{
revenue=revenue+row_price[row];//calculating revenue
seating[row][seat]='#';//making seat unavailable
cout<<"Thankyou for Booking\n";
}
//sorry message
else
{
cout<<"The position yor entered is not available\n See seating chart to know available seats\n";
display();
}
}
//Error message
else
{
cout<<"Invalid seat number or row number....\n";
}
cout<<"Do you want to buy another ticket?\nif yes enter Y or y else N or n\n";
cin>>choice;
}while(choice=='Y'||choice=='y');
//displaying summery of the booking
//seating chart and revenue
cout<<"After booking the seating chart:\n";
display();
cout<<"Total Revenue:\n"<<revenue;
}