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 207 208 209 210 211
|
#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[rows][columns]);
const char FULL ='*';
const char EMPTY = '-';
const int rows = 3;
const int columns = 20;
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 << "\t *** 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;
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\n";
}
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\n";
}
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[rows][columns])
{
for(int y = 0; y < rows; y++)
{
for(int x = 0; x < columns; 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 << '\t';
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 << '\t' <<"Tickets sold " << sold << " $" << sold * price[location] << endl;
amount[location] += sold * price[location];
}
}
cout << "\nTotal 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 << '\t';
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 << '\t' <<"Tickets sold " << sold << " $" << sold * price[day] << endl;
amount[day] += sold * price[day];
}
}
cout << "\nTotal ticket sales for all shows: " << totalSold
<< " $ " << amount[0] + amount[1] + amount[2] << endl << endl;
}
|