hi everyone, i was assigned to make a seating reservation and i was able to make a program, but i have few questions about it here's the code
#include <iostream>
#include <conio.h>
using namespace std;
int movieChoice;
int seatNum;
int seatPlan [5][10]={0};
int rows,cols;
void seatDisplay( int[][10]);
void seatDisplay( int a[][10]){
for (int i=0;i<5;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-4: ";
cin>>rows;
if ((rows > 4) || (rows < 0)) {
cout<<"Invalid row! \n";
goto seatRow;
}
}
return 0;
}
int priceComp(int y){
int price;
price=y*150;
cout<<"You have reserved"<<y<<"seats.";
cout<<endl;
cout<<"Ticket Price: "<<price<<endl;
return 0;
}
int main(){
cout<<"Welcome to Movie World"<<endl;
cout<<"1 - Movie 1"<<endl;
cout<<"2 - Movie 2"<<endl;
cout<<"3 - Movie 3"<<endl;
cout<<endl;
cout<<"Enter your choice of Movie: ";
cin>>movieChoice;
switch (movieChoice){
case 1:
cout<<endl;
cout<<"Movie 1"<<endl;
cout<<"Seating Reservation"<<endl;
seatDisplay(seatPlan);
cout<<"How many seats would you like to reserve?: ";
cin>>seatNum;
seatRes(seatNum);
cout<<"Reservation";
seatPlan[rows][cols] = 1;
cout<<"1 marks your reserved seat \n";
cout<<"------Movie 1 SEAT PLAN----------- \n";
seatDisplay(seatPlan);
priceComp(seatNum);
break;
case 2:
cout<<endl;
cout<<"Movie 2"<<endl;
cout<<"Seating Reservation"<<endl;
seatDisplay(seatPlan);
cout<<"How many seats would you like to reserve?: ";
cin>>seatNum;
seatRes(seatNum);
cout<<"Reservation";
seatPlan[rows][cols] = 1;
cout<<"1 marks your reserved seat \n";
cout<<"------Movie 1 SEAT PLAN----------- \n";
seatDisplay(seatPlan);
priceComp(seatNum);
break;
case 3:
cout<<endl;
cout<<"Movie 3"<<endl;
cout<<"Seating Reservation"<<endl;
seatDisplay(seatPlan);
cout<<"How many seats would you like to reserve?: ";
cin>>seatNum;
seatRes(seatNum);
cout<<"Reservation";
seatPlan[rows][cols] = 1;
cout<<"1 marks your reserved seat \n";
cout<<"------Movie 1 SEAT PLAN----------- \n";
seatDisplay(seatPlan);
priceComp(seatNum);
break;
default:
cout<<endl;
cout<<"Invalid Input"<<endl;
}
return 0;
_getch();
}
-the reserved seat do not display all if the user inputs more than 2 reservation, it only displays 1 seat.
-i would like the reserved seat to be displayed with an 'X' and not '1' but i cant do it