Airline Ticket Reservation

Hello! I have the following assignment:
Write a program to assign passengers seats in an airplane. Assume a small airplane with seat numbering as follows:

1 A B C D
2 A B C D

7 A B C D

The program should display the seat pattern, with an X marking the seats already assigned. For example, after seats 1A, 2B, and 4C are taken, the display should be look like this:

X B C D
A X C D
A B C D
A B X D
A B C D
A B C D
A B C D

After displaying the seats available, the program prompts for the seat desired, the user types in a seat, and then the display of available seats is updated. This continues until all seats are filled or until the user signals that the program should end. If the user types in a seat that is already assigned, the program should say that seat is occupied and ask for another choice.

I am stuck! Is it possible that a function returns a double variable array? This is my code so far
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
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
const int n_of_rows = 7;
const int n_of_columns = 4;
char choose (char seat[][n_of_columns]);
void available (char seat[][n_of_columns]);
void show_seats(char seat[][n_of_columns]);
                 
int main()
{
        char answer;
        do
        {
                cout << "Do you want to find the occurences on a list? (Y/N)\n";
                cin >> answer;
                if (answer == 'Y' || answer == 'y')
                {
                        char seat[n_of_rows][n_of_columns] = { {'A', 'B', 'C', 'D'},
                                                               {'A', 'B', 'C', 'D'},
                                                               {'A', 'B', 'C', 'D'},
                                                               {'A', 'B', 'C', 'D'},
                                                               {'A', 'B', 'C', 'D'},
                                                               {'A', 'B', 'C', 'D'},
                                                               {'A', 'B', 'C', 'D'} };
                        cout << "Welcome to ENGR121 Airline Seat Reservation Program.\n"
                             << "Reserved seats are marked 'X'. Others are available.\n";
                        show_seats (seat);
                        available (seat);
                        choose (seat);
                         seats;
                        show_seats (seats);
                }
                else
                        std::exit(EXIT_FAILURE);
        }
        while(1);
        return EXIT_FAILURE;
}
        
void available (char seats[][n_of_columns])
{
        for (int i = 0; i < n_of_rows; i++)
                for (int j =0; j < n_of_columns; j++)
                        seats[i][j];
        return;
}
char *choose (char seats[][n_of_columns])
{
        int row, column;
        char letter;
        cout << "Enter aisle (1-7):\n";  
        cin >> row;
        if (row < 1 && row > 7)
                cout << "Invalid aisle.\n";
        row--;   
        cout << "Enter seat (A-D):\n";
        cin >> letter;
        letter = toupper(letter);
        column = letter - 65;
        if (seats[row][column] == 'X')
                cout << "This seat has been taken.\n";
        seats[row][column] == 'X';

        return seats[][n_of_columns];
}
                
void show_seats (char seats[][n_of_columns])
{
        for (int i = 0; i < n_of_rows; i++)
                cout << seats[i][0] << "\t"                    
                     << seats[i][1] << "\t"
                     << seats[i][2] << "\t"
                     << seats[i][3] << "\t" << endl;
        return;
}
Are you getting any errors?

Yes, it's possible to return a double array (you have to return a double pointer), but you won't know the size, which could be an issue. That said, looking at the way your program is designed, I don't think you need to. You're already modifying the seats array in your functions already, why do you need to return it?
Topic archived. No new replies allowed.