Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. void display_seats();
  5. void display_seats2();
  6. char seats[15][6];
  7. char seats2[15][6];
  8.  
  9. //reserve seat, seat #, 30 2-3 seatseconomy class, 20 business clas, 10 first class 1
  10.  
  11. int main()
  12. {
  13. //declaration
  14. int colNum, rowNum;
  15. char col_Num;
  16.  
  17. char again = 'N';
  18. //executable
  19.  
  20. for(int row= 0; row<15; row++)
  21. {
  22. for(int col = 0; col <6; col++)
  23. seats [row][col] = 'O';
  24. };
  25. do
  26. {
  27. system ("cls");
  28. display_seats();
  29.  
  30.  
  31.  
  32. do
  33. {
  34. cout<<endl;
  35. cout<<"Enter seat row number[1-15]: ";
  36. cin>>rowNum;
  37. rowNum=rowNum-1;
  38. if(rowNum<0||rowNum>15)
  39. {
  40. cout<<"Enter seat from row number one(1) to fiftheen(15) only! ";
  41. }
  42. }while(rowNum<0||rowNum>15);
  43.  
  44. cout<<"======================================================"<<endl;
  45. do
  46. {
  47.  
  48. cout<<endl;
  49. cout<<"Enter seat coloumn letter[A-E]: ";
  50. cin>>col_Num;
  51. cout<<endl;
  52. col_Num= toupper(col_Num);
  53. if(!(col_Num=='A'||col_Num=='B'||col_Num=='C'||col_Num=='D'||col_Num=='E'||col_Num=='F'));
  54. {
  55. cout<<"Enter seat from letter A to E only: ";
  56.  
  57. }
  58. }while(!(col_Num=='A'||col_Num=='B'||col_Num=='C'||col_Num=='D'||col_Num=='E'||col_Num=='F'));
  59. system ("cls");
  60. if(col_Num=='A')
  61. colNum=0;
  62. if(col_Num=='B')
  63. colNum=1;
  64. if(col_Num=='C')
  65. colNum=2;
  66. if(col_Num=='D')
  67. colNum=3;
  68. if(col_Num=='E')
  69. colNum=4;
  70. if(col_Num=='F')
  71. colNum=5;
  72.  
  73. // to determine whether that seat is already taken
  74. if (seats [rowNum][colNum] == 'X')
  75. {
  76. system ("cls");
  77. cout<<"The seat "<<rowNum<<col_Num<<" is already taken"<<endl;
  78. cout<<"Reserved another seat[Y/N]?";
  79. cin>>again;
  80. }
  81.  
  82. seats[rowNum][colNum]='X';
  83. display_seats() ;
  84. //return rowNum;
  85. //return col_Num;
  86.  
  87.  
  88. cout<<"Reserved another seat[Y/N]?";
  89. cin>>again;
  90. system ("cls");
  91. }while(again=='Y'||again=='y');
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98. }
  99. void display_seats()
  100. {
  101. cout<<"================== SEAT RESERVATION =================="<<endl
  102. <<"row [1-15], coloumn [A-D] "<<endl
  103. <<" ____"<<endl
  104. <<" _------_"<<endl
  105. <<" __________"<<endl
  106. <<" | A B |"<<endl
  107. <<" 1 | "<<seats[0][0]<<" "<<seats[0][1]<<" |"<<endl
  108. <<" 2 | "<<seats[1][0]<<" "<<seats[1][1]<<" |"<<endl
  109. <<" 3 | "<<seats[2][0]<<" "<<seats[2][1]<<" |"<<endl
  110. <<" 4 | "<<seats[3][0]<<" "<<seats[3][1]<<" |"<<endl
  111. <<" 5 | "<<seats[4][0]<<" "<<seats[4][1]<<" |"<<endl
  112. <<" |A B C D|"<<endl
  113. <<" 6 |"<<seats[5][0]<<" "<<seats[5][1]<<" "<<seats[5][2]<<" "<<seats[5][3]<<"|"<<endl
  114. <<" 7 |"<<seats[6][0]<<" "<<seats[6][1]<<" "<<seats[6][2]<<" "<<seats[6][3]<<"|"<<endl
  115. <<" 8 |"<<seats[7][0]<<" "<<seats[7][1]<<" "<<seats[7][2]<<" "<<seats[7][3]<<"|"<<endl
  116. <<" 9 |"<<seats[8][0]<<" "<<seats[8][1]<<" "<<seats[8][2]<<" "<<seats[8][3]<<"|"<<endl
  117. <<" 10 |"<<seats[9][0]<<" "<<seats[9][1]<<" "<<seats[9][2]<<" "<<seats[9][3]<<"|"<<endl
  118. <<" | ABC DEF |"<<endl
  119. <<" 11 | "<<seats[10][0]<<seats[10][1]<<seats[10][2]<<" "<<seats[10][3]<<seats[10][4]<<seats[10][5]<<" |"<<endl
  120. <<" 12 | "<<seats[11][0]<<seats[11][1]<<seats[11][2]<<" "<<seats[11][3]<<seats[11][4]<<seats[11][5]<<" |"<<endl
  121. <<" 13 | "<<seats[12][0]<<seats[12][1]<<seats[12][2]<<" "<<seats[12][3]<<seats[12][4]<<seats[12][5]<<" |"<<endl
  122. <<" 14 | "<<seats[13][0]<<seats[13][1]<<seats[13][2]<<" "<<seats[13][3]<<seats[13][4]<<seats[13][5]<<" |"<<endl
  123. <<" 15 |"<<seats[14][0]<<seats[14][1]<<seats[14][2]<<" "<<seats[14][3]<<seats[14][4]<<seats[14][5]<<"| "<<endl
  124. <<" ________"<<endl
  125. <<" ______"<<endl
  126. <<" ____"<<endl
  127. <<"======================================================"<<endl;
  128. }
  129. void display_seats2()
  130. {
  131. cout<<"================== SEAT RESERVATION =================="<<endl
  132. <<"row [1-15], coloumn [A-D] "<<endl
  133. <<" ____"<<endl
  134. <<" _------_"<<endl
  135. <<" __________"<<endl
  136. <<" | A B |"<<endl
  137. <<" 1 | "<<seats2[0][0]<<" "<<seats2[0][1]<<" |"<<endl
  138. <<" 2 | "<<seats2[1][0]<<" "<<seats2[1][1]<<" |"<<endl
  139. <<" 3 | "<<seats2[2][0]<<" "<<seats2[2][1]<<" |"<<endl
  140. <<" 4 | "<<seats2[3][0]<<" "<<seats2[3][1]<<" |"<<endl
  141. <<" 5 | "<<seats2[4][0]<<" "<<seats2[4][1]<<" |"<<endl
  142. <<" |A B C D|"<<endl
  143. <<" 6 |"<<seats2[5][0]<<" "<<seats2[5][1]<<" "<<seats2[5][2]<<" "<<seats2[5][3]<<"|"<<endl
  144. <<" 7 |"<<seats2[6][0]<<" "<<seats2[6][1]<<" "<<seats2[6][2]<<" "<<seats2[6][3]<<"|"<<endl
  145. <<" 8 |"<<seats2[7][0]<<" "<<seats2[7][1]<<" "<<seats2[7][2]<<" "<<seats2[7][3]<<"|"<<endl
  146. <<" 9 |"<<seats2[8][0]<<" "<<seats2[8][1]<<" "<<seats2[8][2]<<" "<<seats2[8][3]<<"|"<<endl
  147. <<" 10 |"<<seats2[9][0]<<" "<<seats2[9][1]<<" "<<seats2[9][2]<<" "<<seats2[9][3]<<"|"<<endl
  148. <<" | ABC DEF |"<<endl
  149. <<" 11 | "<<seats2[10][0]<<seats2[10][1]<<seats2[10][2]<<" "<<seats2[10][3]<<seats2[10][4]<<seats2[10][5]<<" |"<<endl
  150. <<" 12 | "<<seats2[11][0]<<seats2[11][1]<<seats2[11][2]<<" "<<seats2[11][3]<<seats2[11][4]<<seats2[11][5]<<" |"<<endl
  151. <<" 13 | "<<seats2[12][0]<<seats2[12][1]<<seats2[12][2]<<" "<<seats2[12][3]<<seats2[12][4]<<seats2[12][5]<<" |"<<endl
  152. <<" 14 | "<<seats2[13][0]<<seats2[13][1]<<seats2[13][2]<<" "<<seats2[13][3]<<seats2[13][4]<<seats2[13][5]<<" |"<<endl
  153. <<" 15 |"<<seats2[14][0]<<seats2[14][1]<<seats2[14][2]<<" "<<seats2[14][3]<<seats2[14][4]<<seats2[14][5]<<"| "<<endl
  154. <<" ________"<<endl
  155. <<" ______"<<endl
  156. <<" ____"<<endl
  157. <<"======================================================"<<endl;
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement