the code doesn't debug, why did i do wrong?

this is what i have now. why does it have so many errors? what did i do wrong?

this code gives you 4 options

the first option is suppose to reserve a table
the second option is suppose to clear a table
the third option is suppose to report if table is reserved or not
the fourth option is suppose exit the program



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
#include <iostream>
#include <string>
using namespace std;
void ReserveTable(bool reserveStatus[], int choice);  // size is 20
void ClearTable(bool reserveStatus[], string reserveName[], int size);
void ReportTable(bool reserveStatus[], string reserveName[], int size);

int main()
{	
	// declare variables
	bool reserveStatus[20];
	string reserveName[20];

	// initialize the arrays
	for(int i = 0; i < 20; i++)
	{
		reserveStatus[i] = false;
		reserveName[i] = "none";
	}

	// this is the main loop of the program
	int choice = 0;
	while(choice != 4)
	{
		// display a nice menu
		cout << endl << endl;
		cout << "Please select one of the following options." << endl;
		cout << "1- Reserve a table" << endl;
		cout << "2- Clear reservation" << endl;
		cout << "3- Report" << endl;
		cout << "4- Exit program" << endl;
		cin >> choice;

		if (choice == 1) // user wants to reserve a table
		{				

			cin >> choice;
			ReserveTable(reserveStatus, choice);
		}

		else if (choice == 2)	// user want to cancel a reservation

		{
			ClearTable(reserveStatus, reserveName, size);
		}

		else if (choice == 3)

		{
			ReportTable(reserveStatus, reserveName, size);
		}

		else if (choice == 4)
		{
			break; // exit out of the main loop
		}
	}	

	system("PAUSE");
	return 0;
}

void ReserveTable()

{
	if (reserveStatus[TableNum] == true) 
	{
		cout << "Sorry. The table you requested is already reserved."<< endl;
	}	
	else
	{
		string name; // table is available, let's get the reservation name
		cout << "There seems to be an open seat. What is your last name? "<< endl;
		cin >> name;

		// set the table as reserved and set the reservation name
		reserveStatus[TableNum] = true;
		reserveName[TableNum] = name;

		cout << "Okay, you have reserved a table. Congratulations."<< endl;
	}
}
}
void ClearTable()

	int TableNum; 
cout << "Please select a table number between 0 and 19. " << endl;
cin >> TableNum;
{
	{
		int TableNum;
		cout << "Please select a table number between 0 and 19. "<< endl;
		cin >> TableNum;

		// see if the reservation is already clear on this table
		if (reserveStatus[TableNum] == false)
		{
			cout << "The table reservation you are trying to clear is already available." << endl;
		}	
		else
		{
			// otherwise, clear reservation status
			reserveStatus[TableNum] = false;
			cout << "Okay, the table reservation is now cleared." << endl;
		}
	}
}

void ReportTable()

{ 
	// report all reservations
	for(int i = 0; i < 20; i++)	// go through all tables 0...19
	{
		// see if the table is available
		if (reserveStatus[i] == false)
		{
			cout << "Table :" << i << " is available." << endl;
		}
		else 
		{
			cout << "Table :" << i << " is reserved by " << reserveName[i] << "." << endl;
		}
	}

}
Last edited on
Your function definitions are missing the variables in the parenthesis. The prototypes and definitions have to match.
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
#include <iostream>
#include <string>
using namespace std;
void ReserveTable(bool reserveStatus[], string reserveName[]);
void ClearTable(bool reserveStatus[], string reserveName[]);
void ReportTable(bool reserveStatus[], string reserveName[]);

int main()
{	
	// declare variables
	bool reserveStatus[20];
	string reserveName[20];

	// initialize the arrays
	for(int i = 0; i < 20; i++)
	{
		reserveStatus[i] = false;
		reserveName[i] = "none";
	}

	// this is the main loop of the program
	int choice = 0;
	while(choice != 4)
	{
		// display a nice menu
		cout << endl << endl;
		cout << "Please select one of the following options." << endl;
		cout << "1- Reserve a table" << endl;
		cout << "2- Clear reservation" << endl;
		cout << "3- Report" << endl;
		cout << "4- Exit program" << endl;
		cin >> choice;

		if (choice == 1) // user wants to reserve a table
		{				

			ReserveTable(reserveStatus, reserveName);
		}

		else if (choice == 2)	// user want to cancel a reservation

		{
			ClearTable(reserveStatus, reserveName);
		}

		else if (choice == 3)

		{
			ReportTable(reserveStatus, reserveName);
		}

		else if (choice == 4)
		{
			break; // exit out of the main loop
		}
	}	

	system("PAUSE");
	return 0;
}

void ReserveTable(bool reserveStatus[], string reserveName[])

{
	int tableNum;
	cout << "Which table number would you like? 1 - 20 ";
	cin >> tableNum;
	
	if (reserveStatus[tableNum] == true) 
	{
		cout << "Sorry. The table you requested is already reserved."<< endl;
	}	
	else
	{
		string name; // table is available, let's get the reservation name
		cout << "There seems to be an open seat. What is your last name? "<< endl;
		cin >> name;

		// set the table as reserved and set the reservation name
		reserveStatus[tableNum] = true;
		reserveName[tableNum] = name;

		cout << "Okay, you have reserved a table. Congratulations."<< endl;
	}
}

void ClearTable(bool reserveStatus[], string reserveName[])
{

	int TableNum; 
	cout << "Please select a table number between 0 and 19. " << endl;
	cin >> TableNum;

	// see if the reservation is already clear on this table
	if (reserveStatus[TableNum] == false)
	{
		cout << "The table reservation you are trying to clear is already available." << endl;
	}	
	else
	{
		// otherwise, clear reservation status
		reserveStatus[TableNum] = false;
		cout << "Okay, the table reservation is now cleared." << endl;
	}

}

void ReportTable(bool reserveStatus[], string reserveName[])

{ 
	// report all reservations
	for(int i = 0; i < 20; i++)	// go through all tables 0...19
	{
		// see if the table is available
		if (reserveStatus[i] == false)
		{
			cout << "Table :" << i << " is available." << endl;
		}
		else 
		{
			cout << "Table :" << i << " is reserved by " << reserveName[i] << "." << endl;
		}
	}

}
thanks
Topic archived. No new replies allowed.