Error message confusion

Hi guys, im doing an assignment to create a c++ program that enables a user to book a seat in an airline reservation, i have managed to write out a code but i keep getting two error messages and i have no idea how to fix it, here is my code
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
#include <iostream>
using namespace std;
#include <cctype>
using std::toupper;

int main()
{
	const int seats = 10;
	int flight [seats] = { 0 };
	int passenger = 0;
	int secondclass= 6;
	int firstclass= 1;
	int choice;
	char response;

	while ( passenger < 10 )
	{
		cout << "Welcome to SHARMA Airline reservation system\n";
		cout << "Please, choose which class you would like a seat in:\n";
		cout << "Press 1  for First class\n";
		cout << "Press 2 for Second class\n";

		if ( choice == 1) //if choice 1 (firstclass)
		{
			if ( !flight[ firstclass ] && firstclass <= 5 )
			{
				cout << "You have chosen First class\n";
				cout << "Your seat number is:\n " << firstclass << endl;
				flight [firstclass++] = 1;
				passenger++;
			}
			else if (firstclass > 5 && secondclass <= 10);
			{
				cout << "Sorry, but all the seats in the First class are now full\n";
				cout << "Would you like a seat in the Second class?\n";
				cout << "Please press Y or N\n";
				cin >> response;

			if ( toupper( response ) == 'Y' )
			{
				cout << "You have choosen Second class\n ";
				cout << "Your seat number is:\n" << secondclass << endl;
				flight[ secondclass++ ] = 1;
				passenger++;
			}
			else
				cout << "The next flight leaves in 3 hours\n";
			}
			{
				if ( !flight [secondclass] && secondclass <=10)
				{
					cout << "Your seat is:\n" << secondclass << "in Second class" << endl;
					flight[ secondclass++ ] = 1;
					passenger++;
				}
			else if ( firstclass <=5)
			{
				cout << "The Second class area is full\n";
				cout << "Would you like a seat in the First class section?\n";
				cin >> response;

				if (toupper( response ) == 'Y')
				{
					cout << "You have chosen First class\n";
					cout << "Your seat number is:\n " << firstclass << endl;
					flight [firstclass++] = 1;
					passenger++;
				}
				else 
					cout << "Next flight in 3 hours\n";
				}
			}
		}
	}
	return 0;
}


here are the two warnings i get:

warning C4390: ';' : empty controlled statement found; is this the intent?(line 33)
warning C4700: uninitialized local variable 'choice' used (line 23)

feel free to make any improvements on my codeing aswell im just a begginer!
They are not errors, just warnings, but good warnings that show you the errors you've made.

First one points out that you put a semicolon after the if on line 33.
The second shows you that you don't assign a value to choice before using it on line 23.
Remove the semi colon on line 32.
Also you got int choice i am looking at the program i belive that this is to navigate through the menu, so you might want to add cin >> choice; somewhere.

cos the user will be input this it does not need to be initialiase.

for the first mistake remove semicolon in line 32,

for the line 23 put cin>> choice;

it would be also put a do while loop or while which will prompt a warning and repeat cin>> of choice, if input is not 1 or 2.
Topic archived. No new replies allowed.