I have my final due at 6 tomorrow and I need help on one tiny piece and it'll be finished.
Here's what it needs to do.
1. When the program begins, it should ask the user to enter the seat prices for each row. The prices can be stored in a separate array.
2. Once the prices are entered, the program should display a seating chart. The user may enter the row and seat numbers for tickets being sold. Every time a ticket or group of tickets is sold, the program should display the total ticket prices and update the seating chart.
3. The program should keep a total of all ticket sales. The user should be given the option to view this amount.
4. The program should also give the user an option to see a list of how many seats have been sold, how many seats are available in the entire auditorium.
Task #3 is what I can't figure out.
Here's the code.
// Warren Culp
#include
#include
using namespace std;
int main()
{
const int ROW = 5;
const int ROWS = 5, COLS = 10;
char table[ROWS][COLS] = {{'.', '.', '.', '.', '.', '.', '.', '.', '.', '.'},
{'.', '.', '.', '.', '.', '.', '.', '.', '.', '.'},
{'.', '.', '.', '.', '.', '.', '.', '.', '.', '.'},
{'.', '.', '.', '.', '.', '.', '.', '.', '.', '.'},
{'.', '.', '.', '.', '.', '.', '.', '.', '.', '.'}};
int ticket = 0;
int row = 0, col = 0;
double price[ROW];
int menu;
double total = 0;
cout << setprecision(2) << fixed;
cout << "Please enter the prices for the five rows of the theater" << endl;
cout << "Row 1: $";
cin >> price[0];
cout << "Row 2: $";
cin >> price[1];
cout << "Row 3: $";
cin >> price[2];
cout << "Row 4: $";
cin >> price[3];
cout << "Row 5: $";
cin >> price[4];
cout << endl;
cout << "Welcome to the Shinjuku movie theater" << endl;
for (int x = 0; x < ROWS; x++)
{
for (int y = 0; y < COLS; y++)
{
cout << table[x][y];
}
cout << endl;
}
cout << endl;
cout << "Shinjuku movie theater menu " << endl;
cout << "--------------------------- " << endl;
cout << "1. Purchase a seat" << endl;
cout << "2. View the auditorium" << endl;
cout << "3. Total revenue of all tickets" << endl;
cout << "4. How many seats left in each row" << endl;
cout << "5. How many tickets sold" << endl;
cout << endl;
cout << "Please enter your choice" << endl;
cin >> menu;
while (row < 5)
{
switch (menu)
{
case 1: cout << "Please enter the row you want" << endl;
cin >> row;
cout << "How many seats would you like?" << endl;
cin >> col;
table[row][col] = '#';
if (row == 0)
{
cout << "Your ticket is $" << price[0] << endl;
}
else if (row == 1)
{
cout << "Your ticket is $" << price[1] << endl;
}
else if (row == 2)
{
cout << "Your ticket is $" << price[2] << endl;
}
else if (row == 3)
{
cout << "Your ticket is $" << price[3] << endl;
}
else
{
cout << "Your ticket is $" << price[4] << endl;
}
break;
case 2: cout << "This is the current seating chart of the auditorium" << endl;
cout << " . = Empty seat and # = Filled seat" << endl;
for (int x = 0; x < ROWS; x++)
{
for (int y = 0; y < COLS; y++)
{
cout << table[x][y];
}
cout << endl;
}
break;
case 3: cout << "The total revenue of all tickets sold is $" << total
default: cout << "Please enter a valid choice" << endl;
}
cout << endl;
cout << "Shinjuku movie theater menu " << endl;
cout << "--------------------------- " << endl;
cout << endl;
cout << "1. Purchase a seat" << endl;
cout << "2. View the auditorium" << endl;
cout << "3. Total revenue of all tickets" << endl;
cout << "4. How many seats left in each row" << endl;
cout << "5. How many tickets sold" << endl;
cout << endl;
cout << "Please enter your choice" << endl;
cin >> menu;
}
return 0;
}
Here is an example of what I need help with.
Say if row 1 is $10.50 and row 2 is $8.50.
So user 1 enters row 1 seat whatever and pays 10.50. User 2 does the same thing but for row 2.
Now here comes the problem. When I hit the 3rd case in my switch statement. "Total revenue is << total << endl;
The total doesn't say $19.00, but some other price.
Now I know how to sum up all elements, rows or columns and neither of them work, so how do I add only separate elements?