Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Cant get this code to work, There are some theory issues i need help with, decla

ID: 3647828 • Letter: C

Question

Cant get this code to work, There are some theory issues i need help with, declaring the seats and rows is what i have wrong, i need help with this


#include <iostream>
#include <iomanip>
#include <string>

using namespace std;
void get_menu_choice(char tickets[][3][20]);
void sell_seat(char tickets[][3][20]);
void print_day_list(char tickets[][3][20]);
void print_floor_list(char tickets[][3][20]);
void print_chart(float seats[20][30]);
const char FULL ='*';
const char EMPTY = '-';
const int rows = 20;
const int seats = 30;
const int days = 3;

char map [days][rows][seats];

int main()
{
char tickets[3][3][20];
get_menu_choice(tickets);
print_chart(seats);
sell_seat(tickets);
print_day_list(tickets);
print_floor_list(tickets);


int choice;

do
{
switch(choice)
{
case 'S':
cout << "S - Sell a Ticket.";
sell_seat(tickets);
break;
case 'C':
cout << "C - Display Seating Chart.";
print_chart(seats);
break;
case 'D':
cout << "D - Display Sales Summary - Day Listing";
print_day_list(tickets);
break;
case 'F':
cout << "F - Display Sale Summary - Floor Listing";
print_floor_list(tickets);
break;
case 'Q':
cout << "Quit";
break;
default:
cout << "Invalid choice. Try again!" << endl;
break;
}
}while(choice != 'Q');

cin.clear();
cin.sync();
return 0;
}
void get_menu_choice(char tickets[][3][20])
{
char MenuChoice;

cout << " *** Main Menu *** " << endl;
cout << "S - Sell a Ticket." << endl;
cout << "C - Display Seating Chart." << endl;
cout << "D - Display Sales Summary - Day Listing" << endl;
cout << "F - Display Sale Summary - Floor Listing" << endl;
cout << "Q - Quit" << endl;
cout << "Your Choice: ";
cin >> MenuChoice;
cout << endl;

}
void sell_seat(char tickets[][3][20])
{
char choice, level;
int day, location, Count;

cout << "Enter seat request by day (T)hursday, (F)riday, (S)aturday" << endl;
cout << "followed by Section (F)loor, (B)alcony, (U)pper Balcony" << endl;
cout << "followed by seat number (1-20)." << endl;
cin >> choice >> level >> Count;

choice = toupper(choice);

if (choice == 'T')
day = 0;
else if (choice == 'F')
day = 1;
else if (choice == 'S')
day = 2;
else
{
cout << "Invalid day entered, try again ";

}
cin >> level;
level = toupper(level);
if (level == 'F' )
location = 0;
else if (level == 'B')
location = 1;
else if (level == 'U')
location = 2;
else
{
cout << "Invalid location entered, try again ";

}
for (int Count = 0; Count < 20; Count++)
{
if (tickets[day][location][Count] == '*')
{
tickets[day][location][Count] = 'S';

}
}
cout << "All seats filled for " << choice << " on the " << level << " at seat"
<< Count << " try again" << endl;

}
void print_chart(float seats[20][30])
{
for(int y = 0; y < rows; y++)
{
for(int x = 0; x < 30; x++)
if(seats[y][x] == 0.00)
{
cout << "-";
}
else
{
cout << "*";
}
}
cout << endl;
}
void print_day_list(char tickets[][3][20])
{
string dayTitles[3] = {"Thursday ", "Friday ", "Saturday "};
string locationTitles[3] = {"Floor ", " Balcony ", " Upper Balcony "};
int totalSold = 0, dayTotal[3] = {0}, locationTotal[3] = {0}, sold, dayAmount[3] = {0};
int amount[3] = {0};
int price[3] = {30, 20, 10};
for (int day = 0; day < 3; day ++)
{
cout << dayTitles[day] << endl;
for (int location = 0; location < 3; location++)
{
if(location !=0)
cout << ' ';

cout << locationTitles[location];
sold = 0;
for (int seats = 0; seats < 20; seats++)
{
if(tickets[day][location][seats] == 'S')
{
sold++;
totalSold++;
dayTotal[day]++;
locationTotal[location]++;
dayAmount[day] += price[location];
}
}
cout << ' ' <<"Tickets sold " << sold << " $" << sold * price[location] << endl;
amount[location] += sold * price[location];
}
}
cout << " Total tickets sold for all concerts " << totalSold
<< " $ " << amount[0] + amount[1] + amount[2] << endl << endl;
}
void print_floor_list(char tickets[][3][20])
{
string locationTitles[3] = {"Floor ", "Balcony ", "Upper Balcony "};
string dayTitles[3] = {"Thursday ", " Friday ", " Saturday "};
int totalSold = 0, locationTotal[3] = {0}, dayTotal[3] = {0}, sold, locationAmount[3] = {0};
int amount[3] = {0};
int price[3] = {30, 20, 10};
for (int location = 0; location < 3; location++)
{
cout << locationTitles[location] << endl;
for (int day = 0; day < 3; day++)
{
if(day !=0)
cout << ' ';

cout << dayTitles[day];
sold = 0;
for (int seats = 0; seats < 20; seats++)
{
if(tickets[location][day][seats] == 'S')
{
sold++;
totalSold++;
locationTotal[location]++;
dayTotal[day]++;
locationAmount[location] += price[day];
}
}
cout << ' ' <<"Tickets sold " << sold << " $" << sold * price[day] << endl;
amount[day] += sold * price[day];
}
}
cout << " Total ticket sales for all shows: " << totalSold
<< " $ " << amount[0] + amount[1] + amount[2] << endl << endl;

system("pause");
}

Explanation / Answer


004

005
using namespace std;
006

007
void get_menu_choice(char tickets[][3][20]);
008
void sell_seat(char tickets[][3][20]);
009
void print_day_list(char tickets[][3][20]);
010
void print_floor_list(char tickets[][3][20]);
011
void print_chart(float seats[rows][columns]);
012
const char FULL ='*';
013
const char EMPTY = '-';
014
const int rows = 3;
015
const int columns = 20;
016
const int days = 3;
017
char map [days][rows][seats];
018

019
int main()
020
{
021
char tickets[3][3][20];
022
get_menu_choice(tickets);
023
print_chart(seats);
024
sell_seat(tickets);
025
print_day_list(tickets);
026
print_floor_list(tickets);
027

028
int choice;
029

030
do
031
{
032

choice = get_menu_choice();

switch(choice)
033
{
034
case 'S':
035
cout << "S - Sell a Ticket.";
036
sell_seat(tickets);
037
break;
038
case 'C':
039
cout << "C - Display Seating Chart.";
040
print_chart(seats);
041
break;
042
case 'D':
043
cout << "D - Display Sales Summary - Day Listing";
044
print_day_list(tickets);
045
break;
046
case 'F':
047
cout << "F - Display Sale Summary - Floor Listing";
048
print_floor_list(tickets);
049
break;
050
case 'Q':
051
cout << "Quit";
052
break;
053
default:
054
cout << "Invalid choice. Try again!" << endl;
055
break;
056
}
057
}while(choice != 'Q');
058

059
cin.clear();
060
cin.sync();
061
return 0;
062
}
063
void get_menu_choice(char tickets[][3][20])
064
{
065
char MenuChoice;
066

067
cout << " *** Main Menu *** " << endl;
068
cout << "S - Sell a Ticket." << endl;
069
cout << "C - Display Seating Chart." << endl;
070
cout << "D - Display Sales Summary - Day Listing" << endl;
071
cout << "F - Display Sale Summary - Floor Listing" << endl;
072
cout << "Q - Quit" << endl;
073
cout << "Your Choice: ";
074
cin >> MenuChoice;
075
cout << endl;
076

077
}
078
void sell_seat(char tickets[][3][20])
079
{
080
char choice, level;
081
int day, location;
082

083
cout << "Enter seat request by day (T)hursday, (F)riday, (S)aturday" << endl;
084
cout << "followed by Section (F)loor, (B)alcony, (U)pper Balcony" << endl;
085
cout << "followed by seat number (1-20)." << endl;
086
cin >> choice >> level >> Count;
087

088
choice = toupper(choice);
089

090
if (choice == 'T')
091
day = 0;
092
else if (choice == 'F')
093
day = 1;
094
else if (choice == 'S')
095
day = 2;
096
else
097
{
098
cout << "Invalid day entered, try again ";
099

100
}
101
cin >> level;
102
level = toupper(level);
103
if (level == 'F' )
104
location = 0;
105
else if (level == 'B')
106
location = 1;
107
else if (level == 'U')
108
location = 2;
109
else
110
{
111
cout << "Invalid location entered, try again ";
112

113
}
114
for (int Count = 0; Count < 20; Count++)
115
{
116
if (tickets[day][location][Count] == '*')
117
{
118
tickets[day][location][Count] = 'S';
119

120
}
121
}
122
cout << "All seats filled for " << choice << " on the " << level << " at seat"
123
<< Count << " try again" << endl;
124

125
}
126
void print_chart(float seats[rows][columns])
127
{
128
for(int y = 0; y < rows; y++)
129
{
130
for(int x = 0; x < columns; x++)
131
if(seats[y][x] == 0.00)
132
{
133
cout << "-";
134
}
135
else
136
{
137
cout << "*";
138
}
139
}
140
cout << endl;
141
}
142
void print_day_list(char tickets[][3][20])
143
{
144
string dayTitles[3] = {"Thursday ", "Friday ", "Saturday "};
145
string locationTitles[3] = {"Floor ", " Balcony ", " Upper Balcony "};
146
int totalSold = 0, dayTotal[3] = {0}, locationTotal[3] = {0}, sold, dayAmount[3] = {0};
147
int amount[3] = {0};
148
int price[3] = {30, 20, 10};
149
for (int day = 0; day < 3; day ++)
150
{
151
cout << dayTitles[day] << endl;
152
for (int location = 0; location < 3; location++)
153
{
154
if(location !=0)
155
cout << ' ';
156

157
cout << locationTitles[location];
158
sold = 0;
159
for (int seats = 0; seats < 20; seats++)
160
{
161
if(tickets[day][location][seats] == 'S')
162
{
163
sold++;
164
totalSold++;
165
dayTotal[day]++;
166
locationTotal[location]++;
167
dayAmount[day] += price[location];
168
}
169
}
170
cout << ' ' <<"Tickets sold " << sold << " $" << sold * price[location] << endl;
171
amount[location] += sold * price[location];
172
}
173
}
174
cout << " Total tickets sold for all concerts " << totalSold
175
<< " $ " << amount[0] + amount[1] + amount[2] << endl << endl;
176
}
177
void print_floor_list(char tickets[][3][20])
178
{
179
string locationTitles[3] = {"Floor ", "Balcony ", "Upper Balcony "};
180
string dayTitles[3] = {"Thursday ", " Friday ", " Saturday "};
181
int totalSold = 0, locationTotal[3] = {0}, dayTotal[3] = {0}, sold, locationAmount[3] = {0};
182
int amount[3] = {0};
183
int price[3] = {30, 20, 10};
184
for (int location = 0; location < 3; location++)
185
{
186
cout << locationTitles[location] << endl;
187
for (int day = 0; day < 3; day++)
188
{
189
if(day !=0)
190
cout << ' ';
191

192
cout << dayTitles[day];
193
sold = 0;
194
for (int seats = 0; seats < 20; seats++)
195
{
196
if(tickets[location][day][seats] == 'S')
197
{
198
sold++;
199
totalSold++;
200
locationTotal[location]++;
201
dayTotal[day]++;
202
locationAmount[location] += price[day];
203
}
204
}
205
cout << ' ' <<"Tickets sold " << sold << " $" << sold * price[day] << endl;
206
amount[day] += sold * price[day];
207
}
208
}
209
cout << " Total ticket sales for all shows: " << totalSold
210
<< " $ " << amount[0] + amount[1] + amount[2] << endl << endl;
211
}

#include <iostream>
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote