Advertisement
neptunianCoder

Untitled

Apr 6th, 2020
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.29 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.         Menu();
  88.     }
  89.     while (option != 6);
  90.  
  91. }
  92.  
  93. void seatAvailability(){
  94.  
  95.     cout <<"Available seats " << available_seats << endl;
  96. }
  97.  
  98. void seatBooking(){
  99.  
  100.     cout <<"Choose viewing session type "<< endl
  101.     <<"\1-->Full-Marathon" << endl
  102.     << endl <<"2-->Half-Marathon: ";
  103.     cin >> type;
  104.     //Pay
  105.     if(type==1){
  106.         amount = amount + full;
  107.         //Update seat number
  108.         available_seats = available_seats - 1;
  109.         a_count = a_count+1;
  110.         tickets[a_count][0] = a_count;
  111.         tickets [a_count][1] = 1;
  112.         cout << "Your ticket number is " << tickets[a_count][0] << " and viewing type is Full-Marathon" <<  endl;
  113.  
  114.     }
  115.     else{
  116.         amount = amount + half;
  117.         //Update seat number
  118.         available_seats = available_seats - 1;
  119.         a_count = a_count+1;
  120.         tickets[a_count][0] = a_count;
  121.         tickets [a_count][1] = 2;
  122.         cout << "Your ticket number is " << tickets[a_count][0] << " and viewing type is Half-Marathon" <<  endl;
  123.     }
  124.     Menu();
  125.    
  126. }
  127.  
  128. void freeSeat(){
  129.  
  130.     cout << Freed seats " << f_ticket<< endl;
  131.    cout << endl << "Enter ticket number of seat to free";
  132.    cin >>f_ticket;
  133.    tickets[f_ticket][0] = 0;
  134.    tickets[f_ticket][1] = 0;
  135.    cout << "Seat for ticket " << f_ticket << " is freed" << endl;
  136.  
  137.  
  138. }
  139.  
  140. void grossProfit(){
  141.    cout <<"Gross profit is " << amount << endl;
  142. }
  143. void changeOption(){
  144.    cout << endl <<"Enter ticket number: ";
  145.    cin>>ticket_no;
  146.    if(tickets[ticket_no][1] == 1){
  147.        cout <<"Viewing type is Full-Marathon" <<endl;
  148.        tickets[ticket_no][1] = 2;
  149.        amount = amount - half;
  150.        cout <<"New viewing type for ticket " << tickets[ticket_no][0] <<" is Half-Marathon" <<endl;
  151.    }
  152.    else{
  153.        cout <<"Viewing type is Half-Marathon" <<endl;
  154.        tickets[ticket_no][1] = 1;
  155.        amount = amount + half;
  156.        cout <<"New viewing type for ticket " << tickets[ticket_no][0] <<" is Full-Marathon" <<endl;
  157.    }
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement