Airplane Party program

hey so I'm definitely new at c++ i can sort of understand the language but writing code is where i come across difficulty

im writing an airplane program that for an airline ticketing system. the airline only has two aircraft named ALFA and BRAVO. i need my ticket system to determine the number of seats on each plane and in the lounge. the ticketing system will be installed at the ticket booth for the airline and needs to achieve the following

a) if a party arrives and there is enough room on the plane requested, they are aloud to board and a message to to that effect is printed

b) if a party arrives and there is not enough room on the plane they requested from too many people already being on the plane, they are directed to wait in the lounge and a message displays this as well

c) if a party arrives and there is not enough room on the plane because their party is too big for the plane, they are turned away and a message displays this

d) if a party is directed to the lounge and there is not enough room in the lounge the party is turned away

e) parties are never split

f) a plane will fly when it becomes full and a list of all parties on board will be printed

g) a plane may fly upon the command from the ticket clerk and a list of all parties on board will be printed

h)the ticket clerk will enter when a plane flys in and upon the return of the plane the systems will move people from the lounge to the plane in order of their arrival but will skip parties that cant fit. a list of parties on board will be printed

i) when the airline shits down for the night the airplanes continue to fly and return (without ticket clerk performing any action) until all parties in the lounge have flown with the appropriate messages being printed out

j) party names do not have a maximum size

so far i have a plane that shows the seating arrangements but does not accept parties, only individuals. can someone help me tweak this code to fulfill all the provided data?

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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include<iostream>
#include<cctype>
#include<iomanip>

using namespace std;

void initialize( char form[][6]);
void getData(char& ticketType, int& row, 
             char& column);
void printForm(char form[][6], int row, char column);

int main()
{
    char ch, ticketType, column;
    int row;
    char form[13][6];
    
    initialize( form) ;
    cout << "This program assigns seats for a plane.\n"
         << "Do you want to start now? Y/y for yes, N/n for no." << endl;
    cin >> ch;
    
    ch = static_cast<char>(toupper(ch));
    while(ch == 'Y')     
    { 

        getData(ticketType, row, column);
        printForm(form, row, column);
        
        cout << "This program assigns seats for a plane.\n"
             << "Do you want to start now? Y/y for yes, N/n for no." << endl;
        cin >> ch;
        ch = static_cast<char>(toupper(ch));
        if(ch == 'N')
          return 0;     
    }// end while   

    system("PAUSE");
    return 0;
}

void initialize( char form[][6])
{
     for(int i=0 ;i < 13 ;i++)
       for(int j=0 ;j<6 ;j++)
         form[i][j]='*';
}



void getData(char& ticketType, int& row, char& column)
{          
    cout << "The airplane has 13 rows, with  six seats in each row. " << endl;
           
    cout << "Enter ticket type,\n"
         << "F for first class, \n"
         << "B for business class,\n"
         << "E for economy class:" << endl;
    cin >> ticketType;
    ticketType = static_cast<char>(toupper(ticketType));
    while(ticketType != 'F' && ticketType != 'B' 
          && ticketType && ticketType != 'E')
    {
        cout << "Invalid ticket type." << endl;
        cout << "Enter ticket type,\n"
             << "F for first class, \n"
             << "B for business class,\n"
             << "E for economy class:" << endl;
        cin >> ticketType;
        ticketType = static_cast<char>(toupper(ticketType));
     }      
    switch(ticketType)
    {
           case 'F':
                cout <<  "Row 1 and 2 are first class,\n" ;
                break;
           case 'B':
                cout <<  "row 3 throuh 7 are business class,\n";
                break;
           case 'E':
                cout <<  "row 8 through 13 are economy class." << endl; 
                break;
    }// end switch
                
    cout << "Enter the row number you want to sit: " << endl ;
    cin >> row;  
    
    cout << "Enter the seat number (from A to F). " << endl;
    cin >> column;
    column = static_cast<char>(toupper(column));  
    
}    

void printForm(char form[][6], int row, char column)
{
    int i, j;
  
    if(form[row-1][static_cast<int>(column-65)]=='X')
   {
       cout << "This seat already assigned. Choose another seat: " << endl;
       cin >> column;
       column = static_cast<char>(toupper(column));  
   }  
    form[ row-1 ] [static_cast<int>(column)-65]= 'X';
    
    cout << "* indicates that the seat is available; " << endl; 
    cout << "X indicates that the seat is occupied. " << endl;
    cout << setw(12) << "A" << setw(6) << "B" << setw(6) << "C" 
         << setw(6) << "D" << setw(6) << "E" << setw(6) << "F" << endl;
         
    for(i = 0; i < 13; i++)
    {
       cout << left << setw(3) << "Row " << setw(2)<< i+1 ;
       for(j = 0; j < 6; j++)
       {
          cout << right  << setw(6) << form [i][j];
       }
       cout << endl;
    }

}
Topic archived. No new replies allowed.