Airplane Program

Hello All, I am new to the programming languages and have a program I cannot get to compile.

I am creating a airplane seat reservation program. My plan was as follows:
Create an array that displays 1-15 for rows and on rows 1-5 have 5 columns(4 seats) and the remaining 10 columns have 7 columns(6 seats).
Additionally I wanted to have a menu that ahd 3 options.
1.Reserve
2.display
3.quit

reserve needed to display array and allow to reserve a seat changing the seat to a *.
display would display array and running total of seats

I also needed to upload the seat prices from txt file SeatPrices.txt. Below is my current code, it will not compile, I believe there are issues with my global variables and some syntax issues.

Any help would be appreciated on what you would recomend to accomplish this.
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
  #include <iostream>
#include <cctype>
#include <iomanip>
#include <fstream>
#include <cstring>
#include <cstdlib> 
using namespace std;

//Declare function proto type
char menu;
char answer, seats;
int price1, price2, price3, runningTotal;
const int COLS = 8;
const int ROWS = 16;
void showArray(const int[][COLS], int);

int main()
{
int table1[ROWS][COLS] = {{'0', '1', '2', '3', '4', '5', '6'}, 
								{'1', '0', '0', '0', '0', '0', '0'}, 
								{'2', '0', '0', '0', '0', '0', '0'}, 
								{'3', '0', '0', '0', '0', '0', '0'},
								{'4', '0', '0', '0', '0', '0', '0'},
								{'5', '0', '0', '0', '0', '0', '0'},
								{'6', '0', '0', '0', '0', '0', '0'},
								{'7', '0', '0', '0', '0', '0', '0'},
								{'8', '0', '0', '0', '0', '0', '0'},
								{'9', '0', '0', '0', '0', '0', '0'},
								{'10', '0', '0', '0', '0', '0', '0'},
								{'11', '0', '0', '0', '0', '0', '0'},
								{'12', '0', '0', '0', '0', '0', '0'},
								{'13', '0', '0', '0', '0', '0', '0'},
								{'14', '0', '0', '0', '0', '0', '0'},
								{'15', '0', '0', '0', '0', '0', '0'}};

ifstream infile;
int price1, price2, price3;

infile.open("SeatPrices.txt");

infile >> price1;
infile >> price2;
infile >> price3;

infile.close();

return 0;
}

do
{
		void showArray(table1, ROWS);
		cout << endl << "Menu" << endl << "(1)Reservation:" << endl << "(2)Display: " << endl << "(3)Quit: " << endl;
		cin >> answer;
	while (answer < 1 || answer > 3)
	{
		cout << "Invalid Choice, Please Select Again. ";
		cin >> answer;
	}
		
		if(answer == 1)
	{
		cout << "Welcome to reservations" << endl << "Seats marked with # are available" << endl << "Seats marked with a * are taken " << endl;
	
		void showArray(table1[][COLS], int rows)
		{
			for (int x = 1; x < rows; x++)
			{
				for (int y = 1; y < cols; y++)
				{
					cout << setw(7) << array[x][y] << " ";
				}
			}
		}
		void available(table1[][COLS])
		{
			for (int i = 0; i < ROWS; i++)
				for (int j = 0; j < COLS; j++)
					seats[i][j];
		}
		char choose (int table1[][COLS])
		{
			int row, column, col;
			double firstClass = price1, firstFiveCoach = price2, lastFive = pric3;
			

			cout << endl << "enter Row 1-15: ";
			cin >> row;

			cout << endl << "Enter Seat 1-6: ";
			cin >> col;
			col = toupper(col);
			column = col

				if(row < 1 && row > 15 && col < && row >1, row<6, col 1 > 5, col < 1)
				{
					cout << endl << "Invalid row!! " << endl;
			row--;
				}		

				if (row >=1 && row <= 5)
				{
					cout << endl << "Your first class ticket cost: " << price1 << endl;
					price1 += runningTotal;
				}
				
				if (row >=6 && row <= 10)
				{
					cout << endl << "Your Coach class ticket cost: " << price2 << endl;
					price2 += runningTotal;
				}
				
				if (row >=11 && row <= 15)
				{
					cout << endl << "Your Coach class ticket cost: " << price3 << endl;
					price3 += runningTotal;
				}

				if (seats[row][column] == '*');
				cout << endl << "this seat has been taken." << endl;
				seats[row][column] = '*';
				return seats['*'][COLS];
		}
		

		if(answer == 2)
			void showArray(table1[][COLS], int rows)
		{
			for (int x = 1; x < rows; x++)
			{
				for (int y = 1; y < cols; y++)
				{
					cout << setw(7) << array[x][y] << " ";

				cout >> endl >> "The Total cost of the seats is: " >> runningTotal >> endl;
				}
			}
		}
		if(answer == 3)
			return 0;
		}
}
	



The current errors i recieve are:
Error 1 error C2059: syntax error : 'do' c:\users\microcenter\desktop\jimmy\programming1\course project\course project\project.cpp 50 1 Course Project
4 IntelliSense: expected a declaration c:\Users\microcenter\Desktop\Jimmy\Programming1\Course Project\Course Project\Project.cpp 50 1 Course Project
Error 2 error C2143: syntax error : missing ';' before '{' c:\users\microcenter\desktop\jimmy\programming1\course project\course project\project.cpp 51 1 Course Project
Error 3 error C2447: '{' : missing function header (old-style formal list?) c:\users\microcenter\desktop\jimmy\programming1\course project\course project\project.cpp 51 1 Course Project
5 IntelliSense: this declaration has no storage class or type specifier c:\Users\microcenter\Desktop\Jimmy\Programming1\Course Project\Course Project\Project.cpp 104 6 Course Project
6 IntelliSense: expected a ';' c:\Users\microcenter\Desktop\Jimmy\Programming1\Course Project\Course Project\Project.cpp 104 13 Course Project
7 IntelliSense: expected a declaration c:\Users\microcenter\Desktop\Jimmy\Programming1\Course Project\Course Project\Project.cpp 105 5 Course Project
8 IntelliSense: this declaration has no storage class or type specifier c:\Users\microcenter\Desktop\Jimmy\Programming1\Course Project\Course Project\Project.cpp 120 5 Course Project
9 IntelliSense: expected a ';' c:\Users\microcenter\Desktop\Jimmy\Programming1\Course Project\Course Project\Project.cpp 120 10 Course Project
10 IntelliSense: identifier "row" is undefined c:\Users\microcenter\Desktop\Jimmy\Programming1\Course Project\Course Project\Project.cpp 121 11 Course Project
11 IntelliSense: identifier "column" is undefined c:\Users\microcenter\Desktop\Jimmy\Programming1\Course Project\Course Project\Project.cpp 121 16 Course Project
12 IntelliSense: expected a declaration c:\Users\microcenter\Desktop\Jimmy\Programming1\Course Project\Course Project\Project.cpp 122 5 Course Project
13 IntelliSense: expected a declaration c:\Users\microcenter\Desktop\Jimmy\Programming1\Course Project\Course Project\Project.cpp 123 3 Course Project
14 IntelliSense: expected a declaration c:\Users\microcenter\Desktop\Jimmy\Programming1\Course Project\Course Project\Project.cpp 141 3 Course Project
Last edited on
The do statement is outside of all the blocks.
Also you need to call your functions inside main as when execution reaches the end of main the program terminates.
...you exited out of main well before completing all of your code. Try removing the return 0;, and the following left-hand brace.
Last edited on
Also he is declaring a function in the main a few times anwhen you call functions you dont put the return type
Topic archived. No new replies allowed.