using a dynamic array instead of a static array.

A theater seating chart is implemented as a table of ticket prices.t is a program that asks users to pick either a seat or a price. When choosing seat, indicate the row and column for the location; when choosing the price, randomly choose a seat with that price; mark the sold seats by changing the price to 0. Make sure your code will check whether the seat is available. A loop to determine whether continue to order or not. In each time, the seating chart should be displayed for user.
Can you please modify assignment by using a dynamic array instead of a static array.

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
#include<iostream>
#include<fstream>
using namespace std;
	void output_array(int A[][10])
	{
		for (int i = 0; i<10; i++) 
		{
		for (int j = 0; j<10; j++)
		{
			cout << A[i][j];
			cout << " ";}
		cout << endl;}}
int main()
{
	const int ROWS = 10, COLLUMNS = 10;
	int A[ROWS][COLLUMNS];
	int ttl_amount = 0;
	int tickets = 0;
	ifstream myIn;
	ofstream myOut;
	myIn.open("Text1.txt");
	if (myIn.fail())
	{
		cout << "failed to open file\n";
		system("pause");}
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			myIn >> A[i][j];}}
	char l, k;
	cout << "To book the tickets,press 'Y' " << endl;
	cin >> l;
	cout << endl;
	if ((l == 'y') || (l == 'Y')) 
	{
		do {
			output_array(A);
			int answer, chosn_seat, chosn_price, count, x, y, p1, p2;
			int n, n1;
			count = 0;
			cout << endl;
			cout << "To book by seat number,press '1'" << endl << "To book by price, press '2'" << endl;
			cin >> answer;
			if (answer == 1) 
			{
				cout << "Enter any row number" << endl;
				cin >> n;
				cout << "Enter any collumn number  " << endl;
				cin >> n1;
				if ((n < 11) && (n1 < 11))
				{
					int temp = (A[n - 1][n1 - 1]);
					if (temp == 0) 
					{
						cout << "Seat is already book" << endl;}
					else {
						ttl_amount = ttl_amount + temp;
						cout << "You charged $" << temp << " for this seat " << endl;
						A[n - 1][n1 - 1] = 0;
						tickets = tickets + 1;}}
				else {
					cout << "Select valid row and collumn" << endl;
					system("pause");
				}
			}
			else if (answer == 2) {
				cout << " Enter the price you wanna to choose. " << endl;
				cin >> chosn_price;
				if ((chosn_price == 10) || (chosn_price == 20) || (chosn_price == 30) || (chosn_price == 40) || (chosn_price == 50)) {
					for (x = 0;x < 10 && count < 1;x++) {
						for (y = 0;y < 10 && count < 1;y++) {
							if (A[x][y] == chosn_price) {
								int temp = A[x][y];
								count = count + 1;
								ttl_amount = ttl_amount + temp;
								A[x][y] = 0;
								tickets = tickets + 1;
								break;}}}}
				else {
					cout << "Select valid price" << endl;
					system("pause");}}
			else{
					cout << "select valid option" << endl;
					system("pause");}
					cout << "Press 'Y' to continue and any other key to quit" << endl;
			cin >> k;}
				while ((k == 'y') || (k == 'Y'));}
				cout << "total purchase is;" << ttl_amount << endl;
	cout << "number of tickets;" << tickets << endl;
	myIn.close();
	system("pause");
	return 0;}
	

 
Registered users can post here. Sign in or register to post.