Airline System

I have glitches here in my code that i cannot fix.
*whenever the FIRST class of my code is already full it already full it displays the seat number.

*my main problem here is that i have a difficulty in adding up my code in array. (whenever i do that it all goes blank)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <iostream>
#include <cstdlib>

using namespace std;

int main (){
    const int seat=10;
    int seats[seat]={0};
    int first=1, economy=6, choice, j;
    char k;
    
    cout<<"[1] First Class"<<endl<<"[2] Economy"<<endl;
    
    for(j=1; j<=10; j++){
     do{
      cout<<endl<<"Please Choose:";
      cin>>choice;
      }while(choice<1||choice>2);
      
    if(choice==1){
       cout<<"Seat Number:"<<first<<endl;
               if(first!=6){
                   cout<<endl<<"BOARDING PASS:"<<endl;
                   cout<<"-------------"<<endl;
                   cout<<"Class: First Class"<<endl;
                   cout<<"Seat Number:"<<first<<endl;
                   cout<<"-------------"<<endl;
                   first++;
                   }
               else{
                   cout<<endl<<"FIRST CLASS FULL"<<endl;
                   cout<<"Do you want to transfer to int the ECONOMY SECTION?[y/n]: ";
                   cin>>k;
                          if ((k=='Y'||k=='y')&&economy<=11){
                             cout<<endl<<"Seat Number:"<<economy;
                             cout<<endl<<"BOARDING PASS:"<<endl;
                             cout<<"-------------"<<endl;
                             cout<<"Class: Economy Class"<<endl;
                             cout<<"Seat Number:"<<economy<<endl;
                             cout<<"-------------"<<endl;
                             economy++;
                             }
                          else if ((k=='Y'||k=='y')&&economy>=11){
                             cout<<endl<<"All seats are taken."<<endl;
                             cout<<"Next flight will be in THREE HOURS"<<endl<<endl;
                             }
                          else
                             cout<<"Next Flight will be in THREE HOURS"<<endl;     
                   }     
       }  //end first class
       else{ 
             cout<<"Seat Number:"<<economy<<endl;
               if(economy!=11){
                   cout<<endl<<"BOARDING PASS:"<<endl;
                   cout<<"-------------"<<endl;
                   cout<<"Class: Economy Class"<<endl;
                   cout<<"Seat Number:"<<economy<<endl;
                   cout<<"-------------"<<endl;
                   economy++;
                   }
               else{
                   cout<<endl<<"ECONOMY CLASS FULL"<<endl;
                   cout<<"Do you want to transfer to in the FIRST CLASS SECTION?[y/n]: ";
                   cin>>k;
                          if ((k=='Y'||k=='y')&&first<=6){
                             cout<<endl<<"Seat Number:"<<first;
                             cout<<endl<<"BOARDING PASS:"<<endl;
                             cout<<"-------------"<<endl;
                             cout<<"Class: First Class"<<endl;
                             cout<<"Seat Number:"<<first<<endl;
                             cout<<"-------------"<<endl;
                             first++;
                             }
                          else if ((k=='Y'||k=='y')&&first>=6){
                             cout<<endl<<"All seats are taken."<<endl;
                             cout<<"Next flight will be in THREE HOURS"<<endl<<endl;
                             }
                          else
                             cout<<"Next Flight will be in THREE HOURS"<<endl;
                   } 
       }//end economy
    }// end for
    cout<<endl<<endl;
    system("pause");
    return 0;
}
Please be more exact because I don't really know what is the problem. If you have a problem with that array, don't initialize it. Instead of int seats[seat]={0}; put int seats[seat];. See if it works!
thank you for the reply

You are to write a program to assign seats on each flight of the airline's only plane (capacity: 10 seats).
Your program should display the following menu of alternatives-Please type 1 for
" F i r s t C l a s s " and P l e a s e type 2 for " Economy ". If the person types 1, your program
should assign a seat in the first class section (seats 1 -5). If the person types 2, your program should assign a seat in the economy section (seats 6- 10). Your program should print a boarding pass indicating the person's seat number and whether it is in the first class or economy section of the plane.

Use a single-subscripted array to represent the seating chart of the plane. Initialize all the elements of the array to 0 to indicate that all seats are empty. As each seat is assigned, set the corresponding elements of the array to I to indicate that the seat is no longer available.
Topic archived. No new replies allowed.