Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- void display_seats();
- void display_seats2();
- char seats[15][6];
- char seats2[15][6];
- //reserve seat, seat #, 30 2-3 seatseconomy class, 20 business clas, 10 first class 1
- int main()
- {
- //declaration
- int colNum, rowNum;
- char col_Num;
- char again = 'N';
- //executable
- void reseat_seats()
- do
- {
- system ("cls");
- display_seats();
- do
- {
- cout<<endl;
- cout<<"Enter seat row number[1-15]: ";
- cin>>rowNum;
- rowNum=rowNum-1;
- if(rowNum<0||rowNum>15)
- {
- cout<<"Enter seat from row number one(1) to fiftheen(15) only! ";
- }
- }while(rowNum<0||rowNum>15);
- cout<<"======================================================"<<endl;
- do
- {
- cout<<endl;
- cout<<"Enter seat coloumn letter[A-E]: ";
- cin>>col_Num;
- cout<<endl;
- col_Num= toupper(col_Num);
- if(!(col_Num=='A'||col_Num=='B'||col_Num=='C'||col_Num=='D'||col_Num=='E'||col_Num=='F'));
- {
- cout<<"Enter seat from letter A to E only: ";
- }
- }while(!(col_Num=='A'||col_Num=='B'||col_Num=='C'||col_Num=='D'||col_Num=='E'||col_Num=='F'));
- system ("cls");
- if(col_Num=='A')
- colNum=0;
- if(col_Num=='B')
- colNum=1;
- if(col_Num=='C')
- colNum=2;
- if(col_Num=='D')
- colNum=3;
- if(col_Num=='E')
- colNum=4;
- if(col_Num=='F')
- colNum=5;
- // to determine whether that seat is already taken
- if (seats [rowNum][colNum] == 'X')
- {
- system ("cls");
- cout<<"The seat "<<rowNum<<col_Num<<" is already taken"<<endl;
- cout<<"Reserved another seat[Y/N]?";
- cin>>again;
- }
- seats[rowNum][colNum]='X';
- display_seats() ;
- //return rowNum;
- //return col_Num;
- cout<<"Reserved another seat[Y/N]?";
- cin>>again;
- system ("cls");
- }while(again=='Y'||again=='y');
- }
- void display_seats()
- {
- cout<<"================== SEAT RESERVATION =================="<<endl
- <<"row [1-15], coloumn [A-D] "<<endl
- <<" ____"<<endl
- <<" _------_"<<endl
- <<" __________"<<endl
- <<" | A B |"<<endl
- <<" 1 | "<<seats[0][0]<<" "<<seats[0][1]<<" |"<<endl
- <<" 2 | "<<seats[1][0]<<" "<<seats[1][1]<<" |"<<endl
- <<" 3 | "<<seats[2][0]<<" "<<seats[2][1]<<" |"<<endl
- <<" 4 | "<<seats[3][0]<<" "<<seats[3][1]<<" |"<<endl
- <<" 5 | "<<seats[4][0]<<" "<<seats[4][1]<<" |"<<endl
- <<" |A B C D|"<<endl
- <<" 6 |"<<seats[5][0]<<" "<<seats[5][1]<<" "<<seats[5][2]<<" "<<seats[5][3]<<"|"<<endl
- <<" 7 |"<<seats[6][0]<<" "<<seats[6][1]<<" "<<seats[6][2]<<" "<<seats[6][3]<<"|"<<endl
- <<" 8 |"<<seats[7][0]<<" "<<seats[7][1]<<" "<<seats[7][2]<<" "<<seats[7][3]<<"|"<<endl
- <<" 9 |"<<seats[8][0]<<" "<<seats[8][1]<<" "<<seats[8][2]<<" "<<seats[8][3]<<"|"<<endl
- <<" 10 |"<<seats[9][0]<<" "<<seats[9][1]<<" "<<seats[9][2]<<" "<<seats[9][3]<<"|"<<endl
- <<" | ABC DEF |"<<endl
- <<" 11 | "<<seats[10][0]<<seats[10][1]<<seats[10][2]<<" "<<seats[10][3]<<seats[10][4]<<seats[10][5]<<" |"<<endl
- <<" 12 | "<<seats[11][0]<<seats[11][1]<<seats[11][2]<<" "<<seats[11][3]<<seats[11][4]<<seats[11][5]<<" |"<<endl
- <<" 13 | "<<seats[12][0]<<seats[12][1]<<seats[12][2]<<" "<<seats[12][3]<<seats[12][4]<<seats[12][5]<<" |"<<endl
- <<" 14 | "<<seats[13][0]<<seats[13][1]<<seats[13][2]<<" "<<seats[13][3]<<seats[13][4]<<seats[13][5]<<" |"<<endl
- <<" 15 |"<<seats[14][0]<<seats[14][1]<<seats[14][2]<<" "<<seats[14][3]<<seats[14][4]<<seats[14][5]<<"| "<<endl
- <<" ________"<<endl
- <<" ______"<<endl
- <<" ____"<<endl
- <<"======================================================"<<endl;
- }
- void display_seats2()
- {
- cout<<"================== SEAT RESERVATION =================="<<endl
- <<"row [1-15], coloumn [A-D] "<<endl
- <<" ____"<<endl
- <<" _------_"<<endl
- <<" __________"<<endl
- <<" | A B |"<<endl
- <<" 1 | "<<seats2[0][0]<<" "<<seats2[0][1]<<" |"<<endl
- <<" 2 | "<<seats2[1][0]<<" "<<seats2[1][1]<<" |"<<endl
- <<" 3 | "<<seats2[2][0]<<" "<<seats2[2][1]<<" |"<<endl
- <<" 4 | "<<seats2[3][0]<<" "<<seats2[3][1]<<" |"<<endl
- <<" 5 | "<<seats2[4][0]<<" "<<seats2[4][1]<<" |"<<endl
- <<" |A B C D|"<<endl
- <<" 6 |"<<seats2[5][0]<<" "<<seats2[5][1]<<" "<<seats2[5][2]<<" "<<seats2[5][3]<<"|"<<endl
- <<" 7 |"<<seats2[6][0]<<" "<<seats2[6][1]<<" "<<seats2[6][2]<<" "<<seats2[6][3]<<"|"<<endl
- <<" 8 |"<<seats2[7][0]<<" "<<seats2[7][1]<<" "<<seats2[7][2]<<" "<<seats2[7][3]<<"|"<<endl
- <<" 9 |"<<seats2[8][0]<<" "<<seats2[8][1]<<" "<<seats2[8][2]<<" "<<seats2[8][3]<<"|"<<endl
- <<" 10 |"<<seats2[9][0]<<" "<<seats2[9][1]<<" "<<seats2[9][2]<<" "<<seats2[9][3]<<"|"<<endl
- <<" | ABC DEF |"<<endl
- <<" 11 | "<<seats2[10][0]<<seats2[10][1]<<seats2[10][2]<<" "<<seats2[10][3]<<seats2[10][4]<<seats2[10][5]<<" |"<<endl
- <<" 12 | "<<seats2[11][0]<<seats2[11][1]<<seats2[11][2]<<" "<<seats2[11][3]<<seats2[11][4]<<seats2[11][5]<<" |"<<endl
- <<" 13 | "<<seats2[12][0]<<seats2[12][1]<<seats2[12][2]<<" "<<seats2[12][3]<<seats2[12][4]<<seats2[12][5]<<" |"<<endl
- <<" 14 | "<<seats2[13][0]<<seats2[13][1]<<seats2[13][2]<<" "<<seats2[13][3]<<seats2[13][4]<<seats2[13][5]<<" |"<<endl
- <<" 15 |"<<seats2[14][0]<<seats2[14][1]<<seats2[14][2]<<" "<<seats2[14][3]<<seats2[14][4]<<seats2[14][5]<<"| "<<endl
- <<" ________"<<endl
- <<" ______"<<endl
- <<" ____"<<endl
- <<"======================================================"<<endl;
- }
- void reseat_seats()
- {
- for(int row= 0; row<15; row++)
- {
- for(int col = 0; col <6; col++)
- seats [row][col] = 'O';
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement