Code:
#include <iostream>
using namespace std;
int movieChoice;
int seatNum;
int seatCol;
int seatRow;
int seatPlan [9][10]={10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 20, 20, 20, 20, 20, 20, 10, 10,
10, 10, 20, 20, 20, 20, 20, 20, 10, 10,
10, 10, 20, 20, 20, 20, 20, 20, 10, 10,
20, 20, 30, 30, 40, 40, 30, 30, 20, 20,
20, 30, 30, 40, 50, 50, 40, 30, 30, 20,
30, 40, 50, 50, 50, 50, 50, 50, 40, 30};
int rows,cols;
void seatDisplay( int[][10]);
void seatDisplay( int a[][10]){
for (int i=0;i<9;i++){
for (int j=0;j<10;j++){
cout<<a[i][j];
cout<<" ";
}
cout<<endl;
}
}
int seatRes(int x){
cout<<"Seats: Please enter what seat column and row you wish to reserve: \n";
seatCol:
for (int i=1;i<=x;i++){
cout<<"Seat Column 0-9: ";
cin>>cols;
if ((cols > 10) || (cols < 0)) {
cout<<"Invalid column! \n";
goto seatCol;
}
seatRow:
cout<<"Seat Row 0-10: ";
cin>>rows;
if ((rows > 10) || (rows < 0)) {
cout<<"Invalid row! \n";
goto seatRow;
}
}
return 0;
}
int priceComp(int y){
int price;
price=y*seatPlan[seatCol][seatRow];
cout<<"You have reserved"<<y<<"seats.";
cout<<endl;
cout<<"Ticket Price: "<<price<<endl;
return 0;
}
int main(){
cout<<"Seating Reservation"<<endl;
seatDisplay(seatPlan);
cout<<"How many seats would you like to reserve?: ";
cin>>seatNum;
seatRes(seatNum);
cout<<"Reservation";
seatPlan[rows][cols] = 0;
cout<<"0 marks your reserved seat \n";
cout<<"------Movie 1 SEAT PLAN----------- \n";
seatDisplay(seatPlan);
priceComp(seatNum);
return 0;
}