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 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
|
//Movie Theater Seats and Tickets.
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <vector>
using namespace std;
ofstream outFile;
ifstream inFile;
double subtotal = 0;
const int row = 15;
const int col = 30;
int totalseats = 450;
char seating[row][col] =
{
{'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#'},
{'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#'},
{'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#'},
{'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#'},
{'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#'},
{'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#'},
{'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#'},
{'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#'},
{'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#'},
{'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#'},
{'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#'},
{'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#'},
{'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#'},
{'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#'},
{'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#'},
};
double prices[row][col] =
{
{6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50},
{6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50},
{6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50},
{6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50},
{6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50},
{7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50},
{7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50},
{7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50},
{7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50},
{7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50},
{7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50},
{7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50,7.50},
{6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50},
{6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50},
{6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50,6.50}
};
void availableSeats(); //function prototype
void buySeat ();
int main ()
{
int request;
bool cont = true;
double taxtotal;
double total;
cout << "Welcome to Thomas Cinemas!\n" << endl;
while (cont == true)
{
cout << "Total Seats Available: " << totalseats << "\n" << endl;
cout << "Please enter 1 to view available seating." << endl;
cout << "Or enter 0 to shut down this app." << endl;
cin >> request;
while (request != 1 && request != 0)
{
cout << "Invalid request was made. Enter 1 or 0." << endl;
cin.clear();
cin.ignore();
cin >> request;
}
if (request == 1)
{
availableSeats();
buySeat();
cout << "\nWould you like to continue selecting seats?" << endl;
cout << "2 = Yes or 0 = Checkout" << endl;
cin >> request;
while (request != 2 && request != 0)
{
cout << "Select 2 or 0. Try again." << endl;
cin.clear();
cin.ignore();
cin >> request;
}
if (request == 2)
cont = true;
else if (request == 0)
{
cout << "\nWelcome to checkout!\n" << endl;
cout << "Subtotal: $" << subtotal << endl;
cout << "Sales Tax: 7.0%" << endl;
taxtotal = subtotal * 0.07;
total = subtotal + taxtotal;
cout << "Applicable Tax: $" << taxtotal << endl;
cout << "Total: $" << total << endl;
cout << "\nPRINT TICKETS" << endl;
cout << "Please take your tickets." << endl;
cont = false;
}
}
else if (request == 0)
exit(0);
}
system("pause");
return 0;
}
void availableSeats()
{
cout << " Columns" << endl;
cout << "__________________________________________________" << endl;
cout << " 000000000111111111122222222223" << endl;
cout << " 123456789012345678901234567890" << endl;
cout << "__________________________________________________" << endl;
for (int x = 0; x < 15; x++)
{
if (x <= 8)
cout << "Row " << x + 1 << " | " ;
else if (x >= 9)
cout << "Row " << x + 1 << "| " ;
for (int y = 0; y < 30; y++)
{
cout << seating[x][y];
}
cout << " | " << endl;
}
cout << "__________________________________________________" << endl;
cout << "Rows (1-5) and (13-15) are all $6.50 for each seat." << endl;
cout << "Rows (6-12) are all $7.50 for each seat." << endl;
cout << "__________________________________________________" << endl;
}
void buySeat()
{
int ROW, COL;
double ticket;
cout << "\nPick Row: " << endl;
cin >> ROW;
while (ROW < 1 || ROW > 15)
{
cout << "Try again. Pick a row (1-15)" << endl;
cin.clear();
cin.ignore();
cin >> ROW;
}
cout << "\nPick Column: " << endl;
cin >> COL;
while (COL < 1 || COL > 30)
{
cout << "Try again. Pick a column (1-30)" << endl;
cin.clear();
cin.ignore();
cin >> COL;
}
while (seating[ROW-1][COL-1] == 'X')
{
cout << "Seat already occupied! Try a different seat!" << endl;
cout << "\nPick Row: " << endl;
cin >> ROW;
while (ROW < 1 || ROW > 15)
{
cout << "Try again. Pick a row (1-15)" << endl;
cin.clear();
cin.ignore();
cin >> ROW;
}
cout << "\nPick Column: " << endl;
cin >> COL;
while (COL < 1 || COL > 30)
{
cout << "Try again. Pick a column (1-30)" << endl;
cin.clear();
cin.ignore();
cin >> COL;
}
}
seating[ROW-1][COL-1] = 'X';
totalseats -= 1;
if (ROW >= 1 && ROW <= 5 || ROW >= 13 && ROW <= 15)
{
subtotal += 6.50;
cout << "Ticket: $6.50" << endl;
ticket = 6.50;
cout << setprecision(2) << fixed << "Subtotal: $" << subtotal << endl;
}
else if (ROW >= 6 && ROW <= 12)
{
subtotal += 7.50;
cout << "Ticket: $7.50" << endl;
ticket = 7.50;
cout << setprecision(2) << fixed << "Subtotal: $" << subtotal << endl;
}
}
|