Program 'Ends' after Menu Option Is Selected

Could use some direction on what I am doing wrong! I believe I have the code completed to according to the given requirements but am not able to get it to do anything after the user selects a menu option. Also I can not get the SalePrice.txt file to import the numbers listed within which are:

324.23
200.00
150.23

This is for an assignment that is due today so any help in figuring out what I have done wrong would be greatly appreciated.

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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/*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 :
	1  2		3  4
Row 1 	#  # 		#  #
Row 2 	#  # 		#  #
Row 3 	#  # 		#  #
Row 4 	#  # 		#  #
Row 5 	#  # 		#  #
	1  2  3		4  5  6
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.*/


#include <iostream>
#include <iomanip>
#include <fstream>

using namespace std;

const int ROW = 6;
const int COL = 15;
const int SPA = 3;
const int Seat_CHART		= 1;
const int Seat_EMPTY_ROW	= 2;
const int Seat_EMPTY_TOT	= 3;
const int Sales_TOTAL		= 4;

float total_sales = 0;
int Empty1stClass = 0;
int Empty2ndClass = 0;
int Empty3rdClass = 0;
int menu_choice;
 
int Seat_Price [SPA];
int Display_Menu(int);
void getSEAT_CHART(int[][COL], int);
void getEMPTY_SEATS(int[][COL], int);
int getEMPTY_PER_CLASS(int[][COL], int);
float getSALES_TOTAL(float[][COL], int);

int main()
{

	menu_choice = Display_Menu();



switch (menu_choice)
	{
		case 1: (menu_choice == 1);
		{
			cout << getSEAT_CHART;

			break;
		}
		case 2: (menu_choice == 2);
		{
			cout << getEMPTY_SEATS;

			break;
		}
		case 3: (menu_choice == 3);
		{
			cout << getEMPTY_PER_CLASS;

			break;
		}
		case 4: (menu_choice == 4);
		{
			cout << getSALES_TOTAL;

			break;
		}
	default:
		{
			break;
		}
	}

	ifstream inputFile;
			inputFile.open("C:User1\Desktop\SeatPrices.txt");
		int counter = 0;
				while (counter < SPA && inputFile >> Seat_Price[counter])
				counter++;
		inputFile.close();

		cout << "The Prices are: " << endl;

		for (counter = 0; counter < SPA; counter++)
			cout << Seat_Price[counter] << endl;



		return 0;
	}

	int Display_Menu(int)
{
		int menu_choice;

	cout << "Welcome and thank you for flying with us! Please select an option below by selecting 1-4: \n " << endl;
	cout << "========================================================================================= \n" << endl;
	cout << "1. View Seating Chart and Reserve Seat" << endl;
	cout << "2. View Available Seats by Row" << endl;
	cout << "3. View Available Seats by Class" << endl;
	cout << "4. View Flight Sales Total" << endl;
	cin >> menu_choice;

	while (menu_choice < 1 || menu_choice > 4)
	{
		cout << "Invalid Option! Please select options 1-4" << endl;
		cin >> menu_choice;
		return menu_choice;
	}
	return menu_choice;
}
void getSEAT_CHART(int[][COL], int row)
{
	cout << "Column" << "1" << "2" << "3" << "4" << "5" << "6" << endl;

	for (int r = 0; r < row; r++)
	{
		cout << "Row" << (r + 1) << " " << endl;
		for (int c = 0; c < COL; c++)
		{
			cout << "#" << endl;
		}
	}
}

void getEMPTY_SEATS(int seats_e [][COL], int rows)
{

	for (int count = 0; count < rows; count++)
		
	{
		int total = 0;
		for (int c = 0; c < COL; c++)
		{
			total += seats_e [rows][COL];
		}
	}
}
int getEMPTY_PER_CLASS(int empty_seats[][COL], int row)
{
	int e_seats = 0;
	for (int s = 0; s < row; s++)
	{
		for (int t = 0; t < COL; t++)
			e_seats += empty_seats[row][COL];
	
	}
	
	if (Empty1stClass >= 1 && Empty1stClass <= 5)
	{
		empty_seats += Empty1stClass;
		cout << "The total empty seats in first class is " << empty_seats << endl;
		return Empty1stClass;
	}
	else if (Empty2ndClass >=6 && Empty2ndClass <= 10)
	{
		empty_seats += Empty2ndClass;
		cout << "The total empty seats in Economy Plus is " << empty_seats << endl;
		return Empty2ndClass;
	}
	else if (Empty3rdClass >= 11 && Empty3rdClass <= 15)
	{
		empty_seats += Empty3rdClass; 
		cout << "The total empty seats in Economy is " << empty_seats << endl;
		return Empty3rdClass;
	}
}

float getSALES_TOTAL(float sales[][COL], int row)
{
	float total_sales = 0;
	for (int r = 0; r < row; r++)
	{
		for (int c = 0; c < COL; c++)
			total_sales += sales[row][COL];
	}

	cout << "The total sales made for the flight was: $ " << sales << endl;
	return 0;
}

Last edited on
Topic archived. No new replies allowed.