Advertisement
neptunianCoder

Untitled

Apr 5th, 2020
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.30 KB | None | 0 0
  1. #include <iostream>
  2. void Menu();
  3. void seatAvailability();
  4. void seatBooking();
  5. void freeSeat();
  6. void grossProfit();
  7. void changeOption();
  8.  
  9. int ticket_no,type,free_seats,f_ticket, amount, a_count;
  10. const int half = 5000;
  11. const int full = 10000;
  12. int available_seats =20;
  13. int tickets[20][2];
  14. using namespace std;
  15.  
  16. int main()
  17. {
  18.     Menu();
  19.  
  20. return 0;
  21. }
  22.  
  23.  
  24. void Menu(){
  25. //Menu
  26.     cout <<" Movie Theatre System" << endl
  27.     <<"||     WELCOME         ||" << endl
  28.     <<" *************************  " << endl << endl
  29.     <<" MAIN MENU: " << endl
  30.     <<"1--> View seats" << endl
  31.     <<"2--> Book seats" << endl
  32.     <<"3--> Free up seats" << endl
  33.     <<"4--> Gross Profit" << endl
  34.     <<"5--> Change Option" << endl
  35.     <<"6--> Quit" << endl;
  36.  
  37.     //Selection
  38.     int option;
  39.  
  40.     do{
  41.  
  42.  
  43.         cout << endl << "Please select an option: ";
  44.  
  45.         cin >> option;
  46.  
  47.         switch (option)
  48.         {
  49.  
  50.         case 1:
  51.  
  52.             seatAvailability();
  53.             break;
  54.  
  55.         case 2:
  56.  
  57.             seatBooking();
  58.             break;
  59.  
  60.         case 3:
  61.  
  62.             freeSeat();
  63.             break;
  64.  
  65.         case 4:
  66.  
  67.             grossProfit();
  68.             break;
  69.  
  70.         case 5:
  71.  
  72.             changeOption();
  73.             break;
  74.  
  75.         case 6:
  76.  
  77.             cout << "Out of range" << endl;
  78.             break;
  79.  
  80.         default:
  81.  
  82.             cout <<"Please choose a valid option:" << endl
  83.                 << " =============================" << endl;
  84.             cin.ignore();
  85.  
  86.         }
  87.     }
  88.     while (option != 6);
  89.  
  90. }
  91.  
  92. void seatAvailability(){
  93.  
  94.     cout <<"Available seats " << available_seats << endl;
  95. Menu();    
  96. }
  97.  
  98.  
  99. void seatBooking(){
  100.  
  101.     cout <<" Choose viewing session type "<< endl
  102.     <<"1-->Full-Marathon" << endl
  103.     << endl <<"2-->Half-Marathon: ";
  104.     cin >> type;
  105.     //Pay
  106.     if(type==1){
  107.         amount = amount + full;
  108.         //Update seat number
  109.         available_seats = available_seats - 1;
  110.         a_count = a_count+1;
  111.         tickets[a_count][0] = a_count;
  112.         tickets [a_count][1] = 1;
  113.         cout << "Your ticket number is " << tickets[a_count][0] << " and viewing type is Full-Marathon" <<  endl;
  114.  
  115.     }
  116.     else{
  117.         amount = amount + half;
  118.         //Update seat number
  119.         available_seats = available_seats - 1;
  120.         a_count = a_count+1;
  121.         tickets[a_count][0] = a_count;
  122.         tickets [a_count][1] = 2;
  123.         cout << "Your ticket number is " << tickets[a_count][0] << " and viewing type is Half-Marathon" <<  endl;
  124.     }
  125. Menu();
  126.  
  127. }
  128.  
  129.  
  130. void freeSeat(){
  131.  
  132.     cout << "Freed seats " << f_ticket<< endl;
  133.     cout << endl << "Enter ticket number of seat to free";
  134.     cin >>f_ticket;
  135.     tickets[f_ticket][0] = 0;
  136.     tickets[f_ticket][1] = 0;
  137.     cout << "Seat for ticket " << f_ticket << " is freed" << endl;
  138.  
  139. Menu();
  140. }
  141.  
  142.  
  143. void grossProfit(){
  144.     cout <<"Gross profit is " << amount << endl;
  145. }
  146. void changeOption(){
  147.     cout << endl <<"Enter ticket number: ";
  148.     cin>>ticket_no;
  149.     if(tickets[ticket_no][1] == 1){
  150.         cout <<"Viewing type is Full-Marathon" <<endl;
  151.         tickets[ticket_no][1] = 2;
  152.         amount = amount - half;
  153.         cout <<"New viewing type for ticket " << tickets[ticket_no][0] <<" is Half-Marathon" <<endl;
  154.     }
  155.     else{
  156.         cout <<"Viewing type is Half-Marathon" <<endl;
  157.         tickets[ticket_no][1] = 1;
  158.         amount = amount + half;
  159.         cout <<"New viewing type for ticket " << tickets[ticket_no][0] <<" is Full-Marathon" <<endl;
  160.     }
  161. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement