Airplane Seats

Hey there people, back again, below is what my project is supposed to be. The errors I am getting are in line 54 and 178.
Line 54: Expected '(' for function-style cast or type of construction.
Line 178: Expected ';' at the end of declaration.

Im not sure why I'm getting theses if anyone can help that would be great.

This program will allow the user to keep track of airline reservations. The program should display the seating chart for the airplane. It will use an * to indicate a seat is taken and the # to indicate the seat is available. The program will also display a menu which provides the user with several options. There will be two types of seats in the airplane: first class and coach, each of which will have a different cost. The program must make use of files, arrays and functions.

The airplane will have 5 rows in the first class section with 4 seats in each row, 2 on each side of the aisle and 10 rows in the coach section with 3 seats on each side of the aisle. The prices for all the first class seats will be the same. The first 5 rows of coach will be more expensive than the last 5 rows. The prices for the seats will be stored in a file called SeatPrices.txt . The program should read these values from the file and store the values in an array of doubles. This is an example of the seating chart:

12 34
Row 1 ## ##
Row 2 ## ##
Row 3 ## ##
Row 4 ## ##
Row 5 ## ##
123 456
Row 6 ### ###
Row 7 ### ###
Etc.
The menu will provide choices to reserve a seat(s) and display the total number of seats sold (indicating first class and coach), the total number of seats empty in a row, the total number of seats empty in the plane (indicating first class and coach), and the total amount of sales (in dollars).

Validation: The seat requested by the user is a valid row and seat number. The program should also make sure the seat is not already taken
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
      #include <iostream>
	#include <string>
	#include <fstream>
	#include <ctime>
	#include <cstdlib>
	using namespace std;

	//function declarations
	void init();
	void menu();
	void checkSeat();
    void printTicket();
	void displaySeating();

	//global variables
	const int firstClassPrice = 10000;
	const int economyPrice = 5000;
	const int rows = 9;
	const int columns = 5;
	const int size = 50;
	char seat[rows][columns];
	double price, discount;
	string type, sname, name[rows][columns];
	bool answer;
	void init()
{
    char letters[11] = "ABCDEFGHIJ";
    char letter;
  /* while variable int row is smaller than our maximum amount of rows (10)*/
  for ( int row = 0; row < rows; row++ )
  {
        //assign the letter of the current row to letter variable;
        letter = letters[row];
        //for every seat in a row
        for ( int column = 0; column < 5; column++ )
        {
            //make seat['A'][0] for instance empty
            seat[letter][column] = '0';
        }
    }
}	void menu()
	        {
                {
    	            cout << "Welcome to taxiflite.com\n";
    	            cout << "Please choose one of the following:\n ";
    	            cout << "1. First Class\n";
    	            cout << "2. Economy\n";
    	            cout << "3. Seating allocation\n";
    	            cout << "4. Ticket holder\n";
    	        }

    	void checkSeat()
    	        {
        	            char
        
        	            cout << "Enter name:";
        	            cin >> sname;
        
        	            cout << "Do you want a specific seat:(y/n) : ";
        	            cin >> reply;
                 	            if( reply == 'y' )
            	               {
                	                init();
                	                cout << "Enter seat: \n";
                	                cin >> seat[rows][columns];
                
                	            if(seat[rows][columns] == 'X')
                    	             {
                        	         seat[rows][columns] = 'X';
                        	         name[rows][columns] = sname;
                        	                   }
                
                	                else
                    	                   {
                        	            int x = rand()%rows;
                        	            int y = rand()%columns;
                        	            while(seat[x][y] == 'X');
                                                {
                            	                  int x = rand()%rows;
                            	                  int y = rand()%columns;
                            	                        }
                        
                        	                    seat[rows][columns] = 'X';
                        	                    name[rows][columns] = sname;
                        	                   }
                	               }
        	            else
            	              {
                	                init();
                	                int rows = rand()%rows;
                	                int columns = rand()%columns;
                	                while ( seat[rows][columns] = 'X')
                	                {
                        	           int rows = rand()%rows;
                        	           int columns = rand()%columns;
                        	                       }
                	                seat[rows][columns] = 'X';
                	                name[rows][columns] = sname;
                	              }
        	          

    	        void printTicket()
    	            {
        
        	                cout <<"Name: " << name << endl;
        	                cout << "Seat No: " << seat << endl;
        	                cout << "Ticket type: " << type << endl;
        	                cout << "price: " << price << endl;
        	            }

    	        void displaySeating()
    	            {
        	            }

    	int main()
    	{
        	    int choice;
        	    srand(time(NULL)); //need this for random numbers
        	    for ( int count = 0 ; count < 50 ; count++)
            	    {
                	        menu();
                	        cin >> choice;
                	        switch (choice)
                	       {
                    	            case 1:
                    	                type = "First class";
                    	                init();
                                   int rows = 9;
                        	     {
                            	         checkSeat();
                            	         bool isleSeat1 = seat[rows][1];
                            	         bool isleSeat2 = seat[rows][2];
                           if ( isleSeat1 == true ||  isleSeat2 == true )
                                	                            {
                                    	                                                    discount = 10 / 100 * firstClassPrice;
                   price = firstClassPrice - discount;
                                    	                            }
                            	                        else
                                	                            {
                                    	        price = firstClassPrice;
                                    	                            }
                            	                   }
                    	                break;
                    	              
                    	            case 2:
                    	                type = "Economy";
                    	                init();
                    	                while( rows > 2 )
                        	                {
                            	                    checkSeat();
                            	             bool isleSeat1 = seat[rows][1];
                            	             bool isleSeat2 = seat[rows][2];
      if ( isleSeat1 == true ||  isleSeat2 == true )
{
                                    	                                discount = 10 / 100 * firstClassPrice;
price = firstClassPrice - discount;
                                }
       else
{
                        price = firstClassPrice;
                      }
                            	  }
                  break;
                    	              
                    	             case 3:
                    	                printTicket();
                    	                break;
                    	              
                    	            case 4:
                    	              
                    	            default:
                    cout << "Incorrect. Choose between 1-4 \n";
                    	             
                    	         
                    	       }
                	    }
        	    return 0;
        }
It would help a lot if your indentation was better, but you have an extra curly brace on line 43.
You're also missing a closing brace for your checkSeat function.

And take a look at line 54.
I added reply to line 54 still getting the same error
you are missing one on line 51 also..If you had proper indentation you would clearly see the problems :P Using an online formatter (not the best) you can see some of the problems:

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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#include <iostream>
#include <string> 
#include <fstream>
#include <ctime> 
#include <cstdlib> 
using namespace std;
//function declarations void init();
void menu();
void checkSeat();
void printTicket();
void displaySeating();
//global variables const int firstClassPrice = 10000;
const int economyPrice = 5000;
const int rows = 9;
const int columns = 5;
const int size = 50;
char seat[rows][columns];
double price, discount;
string type, sname, name[rows][columns];
bool answer;
void init()
{
    char letters[11] = "ABCDEFGHIJ";
    char letter;
    /* while variable int row is smaller than our maximum amount of rows (10)*/ for ( int row = 0; row < rows; row++ )
    {
        //assign the letter of the current row to letter variable;
        letter = letters[row];
        //for every seat in a row for ( int column = 0;
        column < 5;
        column++ )
        {
            //make seat['A'][0] for instance empty seat[letter][column] = '0';
        }
    }
}
void menu()
{
    {
        cout << "Welcome to taxiflite.com\n";
        cout << "Please choose one of the following:\n ";
        cout << "1. First Class\n";
        cout << "2. Economy\n";
        cout << "3. Seating allocation\n";
        cout << "4. Ticket holder\n";
    }
    void checkSeat()
    {
        char cout << "Enter name:";
        cin >> sname;
        cout << "Do you want a specific seat:(y/n) : ";
        cin >> reply;
        if( reply == 'y' )
        {
            init();
            cout << "Enter seat: \n";
            cin >> seat[rows][columns];
            if(seat[rows][columns] == 'X')
            {
                seat[rows][columns] = 'X';
                name[rows][columns] = sname;
            }
            else
            {
                int x = rand()%rows;
                int y = rand()%columns;
                while(seat[x][y] == 'X');
                {
                    int x = rand()%rows;
                    int y = rand()%columns;
                }
                seat[rows][columns] = 'X';
                name[rows][columns] = sname;
            }
        }
        else
        {
            init();
            int rows = rand()%rows;
            int columns = rand()%columns;
            while ( seat[rows][columns] = 'X')
            {
                int rows = rand()%rows;
                int columns = rand()%columns;
            }
            seat[rows][columns] = 'X';
            name[rows][columns] = sname;
        }
        void printTicket()
        {
            cout <<"Name: " << name << endl;
            cout << "Seat No: " << seat << endl;
            cout << "Ticket type: " << type << endl;
            cout << "price: " << price << endl;
        }
        void displaySeating()
        {
        }
        int main()
        {
            int choice;
            srand(time(NULL));
            //need this for random numbers  for ( int count = 0 ;
            count < 50 ;
            count++)
            {
                menu();
                cin >> choice;
                switch (choice)
                {
                    case 1:  type = "First class";
                    init();
                    int rows = 9;
                    {
                        checkSeat();
                        bool isleSeat1 = seat[rows][1];
                        bool isleSeat2 = seat[rows][2];
                        if ( isleSeat1 == true || isleSeat2 == true )
                        {
                            discount = 10 / 100 * firstClassPrice;
                            price = firstClassPrice - discount;
                        }
                        else
                        {
                            price = firstClassPrice;
                        }
                    }
                    break;
                    case 2:  type = "Economy";
                    init();
                    while( rows > 2 )
                    {
                        checkSeat();
                        bool isleSeat1 = seat[rows][1];
                        bool isleSeat2 = seat[rows][2];
                        if ( isleSeat1 == true || isleSeat2 == true )
                        {
                            discount = 10 / 100 * firstClassPrice;
                            price = firstClassPrice - discount;
                        }
                        else
                        {
                            price = firstClassPrice;
                        }
                    }
                    break;
                    case 3:  printTicket();
                    break;
                    case 4: default: cout << "Incorrect. Choose between 1-4 \n";
                }
            }
            return 0;
        }
@giblit, I see you have done this project before?
No. That is your code. The problem is you are missing a bunch of closing braces to your functions.
Last edited on
ok added some extra brackets where i was missing some I'm still getting errors on line:
31 (read only variable is not assigned)
49 (Expected "(" for function-style cast or type construction)
153 (Expected ";" at end of declaration)


This is Driving me NUTS.
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#include <iostream>
#include <string>
#include <fstream>
#include <ctime>
#include <cstdlib>
using namespace std;
//function declarations void init();
void menu();
void checkSeat();
void printTicket();
void displaySeating();
//global variables const int firstClassPrice = 10000;
const int economyPrice = 5000;
const int rows = 9;
const int columns = 5;
const int size = 50;
char seat[rows][columns];
double price, discount;
string type, sname, name[rows][columns];
bool answer;
void init()
{
    char letters[11] = "ABCDEFGHIJ";
    char letter;
    /* while variable int row is smaller than our maximum amount of rows (10)*/ for ( int row = 0; row < rows; row++ )
    {
        //assign the letter of the current row to letter variable;
        letter = letters[row];
        //for every seat in a row for ( int column = 0;
        columns < 5;
                columns ++

            //make seat['A'][0] for instance empty seat[letter][column] = '0';
        }
    }

void menu()
{
    {
        cout << "Welcome to taxiflite.com\n";
        cout << "Please choose one of the following:\n ";
        cout << "1. First Class\n";
        cout << "2. Economy\n";
        cout << "3. Seating allocation\n";
        cout << "4. Ticket holder\n";
    }
    void checkSeat()
    {
        char cout << "Enter name:";
        cin >> sname;
        cout << "Do you want a specific seat:(y/n) : ";
        cin >> reply;
        if( reply == 'y' )
        {
            init();
            cout << "Enter seat: \n";
            cin >> seat[rows][columns];
            if(seat[rows][columns] == 'X')
            {
                seat[rows][columns] = 'X';
                name[rows][columns] = sname;
            }
            else
            {
                int x = rand()%rows;
                int y = rand()%columns;
                while(seat[x][y] == 'X');
                {
                    int x = rand()%rows;
                    int y = rand()%columns;
                }
                seat[rows][columns] = 'X';
                name[rows][columns] = sname;
            }
        }
        else
        {
            init();
            int rows = rand()%rows;
            int columns = rand()%columns;
            while ( seat[rows][columns] = 'X')
            {
                int rows = rand()%rows;
                int columns = rand()%columns;
            }
            seat[rows][columns] = 'X';
            name[rows][columns] = sname;
        }
        void printTicket()
        {
            cout <<"Name: " << name << endl;
            cout << "Seat No: " << seat << endl;
            cout << "Ticket type: " << type << endl;
            cout << "price: " << price << endl;
        }
        void displaySeating()
        {
        }
        int main()
        {
            int choice;
            srand(time(NULL));
            //need this for random numbers  for ( int count = 0 ;
            count < 50 ;
            count++)
            {
                menu();
                cin >> choice;
                switch (choice)
                {
                    case 1:  type = "First class";
                        init();
                        int rows = 9;
                    {
                        checkSeat();
                        bool isleSeat1 = seat[rows][1];
                        bool isleSeat2 = seat[rows][2];
                        if ( isleSeat1 == true || isleSeat2 == true )
                        {
                            discount = 10 / 100 * firstClassPrice;
                            price = firstClassPrice - discount;
                        }
                        else
                        {
                            price = firstClassPrice;
                        }
                    }
                        break;
                    case 2:  type = "Economy";
                        init();
                        while( rows > 2 )
                        {
                            checkSeat();
                            bool isleSeat1 = seat[rows][1];
                            bool isleSeat2 = seat[rows][2];
                            if ( isleSeat1 == true || isleSeat2 == true )
                            {
                                discount = 10 / 100 * firstClassPrice;
                                price = firstClassPrice - discount;
                            }
                            else
                            {
                                price = firstClassPrice;
                            }
                        }
                        break;
                    case 3:  printTicket();
                        break;
                    case 4: default: cout << "Incorrect. Choose between 1-4 \n";
                }
            }
            return 0;
        }
Well line 31 is a pretty straight forward error. You have columns as a read-only variable (constant) and you are trying to modify the value of it. You must remove const(make it read-write) if you wish to do this. line 49 you have a random char not sure why.

Also your return statement is after main function ends. You have an extra brace after it. Menu and checkseat are missing closing braces.

Not sure where you added your braces...
Topic archived. No new replies allowed.