# include <iostream>
# include <iomanip>
usingnamespace std;
void seats( double [] , int);
void mapSeats();
int main()
{
constint rowNum = 20;
double rowValue[rowNum]; //array to hold row pices
char selection;
int row2, col2;
constchar TAKEN = '#';//seats taken
constchar EMPTY = '*';//seats free
constint row = 20;//number of rows
constint col = 15;//number of col
char map[row][col];//array to hold seat chart
for(int i= 0;i<row;i++)//initiating array
{
for (int j=0;j<col;j++)
{
map[i][j]=EMPTY;
}
}
mapSeats();
seats(rowValue, rowNum);//ask user to enter price of each row
cout << endl;
do
{
cout << "MOVIE THEATER MENU" << endl;
cout << "------------------" << endl;
cout << "1) Sell a ticket" << endl;
cout << "2) Total sell and exit" << endl;
cout << "Please make a selection: ";
cin >> selection;
if(selection =='1')
{
cout << "Please enter a row number and a seat number for the ticket: " ;
cout << "Row # :" ;
cin >> row2;
cout << endl;
cout << "Seat # :" ;
cin >> col2;
cout << endl;
// Check if seat is free
if(map[row2][col2] == TAKEN)
{
cout << "This seat is taken! Try another one. \n";
continue; // start the loop again
}
else // and if it is - sell the ticket
map[row2][col2]=TAKEN;
// Add the next loop to immediately see the effects:
for (int i = 0; i < row; i++)
{
for(int j = 0; j < col; j++)
{
cout << map[i][j];
}
cout << endl;
}
}
elseif(selection =='2')
{
cout << "TOTAL TICKETS SOLD: " << endl;
cout << "TOTAL REVENUE: ";
}
elseif(selection != '1' || selection !='q' || selection !='Q')
{
cout << "Invalid selection." << endl;
}
}while(selection != '1' || selection !='q' || selection !='Q');
system("PAUSE");
return 0;
}
void seats(double rowPrice[], int row)
{
int sum;
cout << "Please enter a ticket price for each row." << endl;
for(int i = 0 ; i < row; i++)
{
cout << "Row # " << i+1 << ": " ;
cin >> rowPrice[i];
}
}
void mapSeats()
{
constchar TAKEN = '#';//seats taken
constchar EMPTY = '*';//seats free
constint rw=20;
constint cl=15;
cout << "Seats " ;
for(int k = 0 ; k <15;k++) //loop to display nums 0 to 14
{
cout << fixed<< setw(2) << " " << k ;
}
for(int i=0;i<rw;i++)//making array display what's in it
{
cout << endl<< "Row " << i;
for(int j=0;j<cl;j++)
{
cout << fixed<< setw(2) << "" << EMPTY;
}
}
cout << endl;
}
// I am trying to produce the total number of tickets sold and the total revenue from all tickets sold to be displayed at menu option (2), but i can't figure out how. can someone show me how please?
1) Look at the conditions on lines 79 ad 83. Under what circumstances would you expect that condition to be false?
2) To answer your question, you want to keep a running total of the number of seats sold, and the revenue. Each time a ticket is sold, update those two values. When the user selects option 2, print those values out.