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
|
#include <iostream>
using namespace std;
void display_array(int seatingArray[9][8]);
void check_seating(int seatingArray[9][8], int userRow, int userColumn, bool&
seatTaken);
bool theater_full(int seatingArray[9][8]);
int main()
{
cout << endl << " Theater Seating Program" << endl << endl;
int seatingArray[9][8]
={
{ 40, 50, 50, 50, 50, 50, 50, 40 },
{ 30, 30, 40, 50, 50, 40, 30, 30 },
{ 20, 30, 30, 40, 40, 30, 30, 20 },
{ 10, 20, 20, 20, 20, 20, 20, 10 },
{ 10, 20, 20, 20, 20, 20, 20, 10 },
{ 10, 20, 20, 20, 20, 20, 20, 10 },
{ 10, 10, 10, 10, 10, 10, 10, 10 },
{ 10, 10, 10, 10, 10, 10, 10, 10 },
{ 10, 10, 10, 10, 10, 10, 10, 10 }
};
display_array(seatingArray);
}
void display_array(int seatingArray[9][8])
{
int row,column;
do{
for(int i = 8; i > -1; i--) //This loops on the rows.
{
for(int j = 0; j < 8; j++) //This loops on the columns
{
if(seatingArray[i][j] == -1)
cout << " X ";
else
cout << " $" << seatingArray[i][j];
}
cout << endl;
}
cout << endl << "Which seat would you like? " << endl
<< endl << "Entering a -1 ends the program.." << endl << endl;
cout << "Please select your row ";
cin >> row;
if(row > 0 && row < 9)
{
cout << endl << "Please select your column ";
cin >> column;
if(seatingArray[row - 1][column - 1] != -1)
{
cout << endl << "Thank you for choosing seat #"
<< row << ":" << column << ". Your ticket price is $"
<< seatingArray[row - 1][column - 1] << endl << endl;
seatingArray[row - 1][column - 1] = -1;
}
else
cout << endl << "Sorry, that seat is NOT available."
<< endl << endl << "Please choose another.." << endl << endl;
}
} while (row != -1);
cout << endl << "Program ending" << endl;
}
|