Advertisement
Guest User

Untitled

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