Hello everyone.
I'm supposed to write a code that'll sell seats in a three level auditorium for three different days (Days: Thursday, Friday, and Saturday (T, F, & S); Sections: Floor, Balcony, and Upper Balcony (F, B, & U)) The problem is, I can't even get the sell_seat function to work.
I was wondering if anyone could help me figure out what was wrong with my code (I keep getting
98 [main] william_rodriguez_prog5 6884 open_stackdumpfile: Dumping stack trace to william_rodriguez_prog5.exe.stackdump
whenever I try to run that option.
Anyone know why?
Also, I was hoping someone could point me in the right direction for the other functions in the program. I'm having trouble printing out the seating chart.
print_chart( ): displays seating chart;
print_day_list( ): displays the sales summary, ordered by the days;
print_section_list( ): displays the sales summary, ordered by the section.
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
|
# include <iostream>
# include <iomanip>
# include <cctype>
using namespace std;
char get_menu_choice(char choice);
void sell_seat(char seats[][3][20]);
void print_chart(char seat_chart[3][20]);
/*
void cashier(int var_2);
void print_day_list(int var_4); //Functions I need help with.
void print_section_list(int var_5);
*/
char choice;
char seats[3][3][20];
char seat_chart[3][20];
int main()
{
cout << "Initializing seating chart." << endl << " " << endl;
int d, s, n;
for (d = 0; d < 3; d++) {
for (s = 0; s < 3; s++) {
for (n = 0; n < 20; n++)
seats[d][s][n] = '-';
}
}
cout << "All seats have been initialized." << endl << " " << endl;
do {
choice = get_menu_choice(choice);
choice = toupper(choice);
switch (choice) {
case 'S':
sell_seat(seats);
break;
case 'C':
cout << "You chose C!" << endl;
break;
case 'D':
cout << "You chose D!" << endl;
break;
case 'F':
cout << "You chose F!" << endl;
break;
case 'Q':
cout << "Quit" << endl;
break;
default:
cout << "Invalid selection. Try again." << endl;
break;
}
cout << " " << endl;
} while (choice != 'Q');
return 0;
}
char get_menu_choice(char choice)
{
cout.fill(' ');
cout << setw(22) << "*** Main Menu ***" << endl << "S - Sell a Ticket."
<< endl << "C - Display Seating Chart." << endl
<< "D - Display Sales Summary - Day Listing" << endl
<< "F - Display Sale Summary - Floor Listing" << endl << "Q - Quit"
<< endl << "Your Choice: ";
cin >> choice;
return choice;
}
void sell_seat(char seats[][3][20])
{
int d, s, n;
char seat;
seats[d][s][n] = '-';
cout << "Enter seat request by day (T)hursday, (F)riday, or (S)aturday"
<< endl
<< "followed by section (F)loor, (B)alcony, or (U)pper Balcony"
<< endl << "followed by seat number (1 - 20)." << endl;
cout << "Seat: ";
cin >> seat;
d = toupper(d);
switch (d) {
case 'T':
d = 0;
break;
case 'F':
d = 1;
break;
case 'S':
d = 2;
break;
default:
cout << "Invalid choice try again";
break;
}
s = toupper(s);
switch (s) {
case 'F':
s = 0;
break;
case 'B':
s = 1;
break;
case 'U':
s = 2;
break;
default:
cout << "Invalid choice try again";
break;
}
if (n < 0 || n > 20)
cout << "Invalid seat number." << endl;
else
n -= 1;
if (seats[d][s][n] == '*')
cout << "This seat has been taken." << endl;
else {
seats[d][s][n] = '*';
cout << "Congratulations! You got the seat." << endl;
}
}
void print_chart(char seat_chart[3][20])
{
//I don't know how to start this.
//I know it has to be a 2D array, though.
}
|
Any help is greatly appreciated, I need this in a few days and I'm starting to freak out a bit.