Code:
#include<iostream> using namespace std; int main(){ string seat[7][4]; int row,i,j; char col,response,ok; for(int p=1;p<=7;p++){ cout<<p; seat[p][0]; cout<<"\tA"; seat[p][1]; cout<<"\tB"; seat[p][2]; cout<<"\tC"; seat[p][3]; cout<<"\tD\n"; } do { cout << "\nPlease select seating: "; cin >> row>>col; i = row-1; if (col=='A'||col=='a'){ j = 0; } if (col=='B'||col=='b'){ j = 1; } if (col=='C'||col=='c'){ j = 2; } if (col=='D'||col=='d'){ j = 3; } if (seat[i][j]=="X"){ cout << "This seat has been taken. Please choose a new one." << endl << endl; for(int p=1;p<=7;p++){ cout<<p; seat[p][0]; cout<<"\tA"; seat[p][1]; cout<<"\tB"; seat[p][2]; cout<<"\tC"; seat[p][3]; cout<<"\tD\n"; } } else{ switch(row){ case 1: if (col=='A'||col=='a'){ seat[0][0]="X"; } else if (col=='B'||col=='b'){ seat[0][1]="X"; } else if (col=='C'||col=='c'){ seat[0][2]="X"; } else if (col=='D'||col=='d'){ seat[0][3]="X"; } break; case 2: if (col=='A'||col=='a'){ seat[1][0]="X"; } else if (col=='B'||col=='b'){ seat[1][1]="X"; } else if (col=='C'||col=='c'){ seat[1][2]="X"; } else if (col=='D'||col=='d'){ seat[1][3]="X"; } break; case 3: if (col=='A'||col=='a'){ seat[2][0]="X"; } else if (col=='B'||col=='b'){ seat[2][1]="X"; } else if (col=='C'||col=='c'){ seat[2][2]="X"; } else if (col=='D'||col=='d'){ seat[2][3]="X"; } break; case 4: if (col=='A'||col=='a'){ seat[3][0]="X"; } else if (col=='B'||col=='b'){ seat[3][1]="X"; } else if (col=='C'||col=='c'){ seat[3][2]="X"; } else if (col=='D'||col=='d'){ seat[3][3]="X"; } break; case 5: if (col=='A'||col=='a'){ seat[4][0]="X"; } else if (col=='B'||col=='b'){ seat[4][1]="X"; } else if (col=='C'||col=='c'){ seat[4][2]="X"; } else if (col=='D'||col=='d'){ seat[4][3]="X"; } break; case 6: if (col=='A'||col=='a'){ seat[5][0]="X"; } else if (col=='B'||col=='b'){ seat[5][1]="X"; } else if (col=='C'||col=='c'){ seat[5][2]="X"; } else if (col=='D'||col=='d'){ seat[5][3]="X"; } break; case 7: if (col=='A'||col=='a'){ seat[6][0]="X"; } else if (col=='B'||col=='b'){ seat[6][1]="X"; } else if (col=='C'||col=='c'){ seat[6][2]="X"; } else if (col=='D'||col=='d'){ seat[6][3]="X"; } break; } for(int p=1;p<=7;p++){ cout<<p; seat[p][0]; cout<<"\tA"; seat[p][1]; cout<<"\tB"; seat[p][2]; cout<<"\tC"; seat[p][3]; cout<<"\tD\n";} if (seat[0][0]=="X" && seat[1][0]=="X" && seat[2][0]=="X" && seat[3][0]=="X" && seat[4][0]=="X" && seat[5][0]=="X" && seat[6][0]=="X" && seat[0][1]=="X" && seat[1][1]=="X" && seat[2][1]=="X" && seat[3][1]=="X" && seat[4][1]=="X" && seat[5][1]=="X" && seat[6][1]=="X" && seat[0][2]=="X" && seat[1][2]=="X" && seat[2][2]=="X" && seat[3][2]=="X" && seat[4][2]=="X" && seat[5][2]=="X" && seat[6][2]=="X" && seat[0][3]=="X" && seat[1][3]=="X" && seat[2][3]=="X" && seat[3][3]=="X" && seat[4][3]=="X" && seat[5][3]=="X" && seat[6][3]=="X"){ system("pause"); return 0; }else{ do { cout << "Do you want to continue? [y/n]"; cin >> response; if(response=='y' || response=='n' || response=='N' || response=='Y'){ ok='e'; } else{ ok='p'; } }while(ok=='p'); } } }while(response=='y' || response =='Y'); system("pause"); return 0; }
ok so where went wrong?its suppose to show "x" after i choose d seat
Comment