Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

//I am suppose to display this below at the start of my program to show // the u

ID: 3643781 • Letter: #

Question

//I am suppose to display this below at the start of my program to show
// the user what seats are available and *means seat available and # means
// seat that taken

Seats: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Row 0 * * * * * * * * * * * * * * * * * * * *
Row 1 * * * * * * * * * * * * * * * * * * * *
Row 2 * * * * * * * * * * * * * * * * * * * *
Row 3 * * * * * * * * * * * * * * * * * * * *
Row 4 * * * * * * * * * * * * * * * * * * * *
Row 5 * * * * * * * * * * * * * * * * * * * *
Row 6 * * * * * * * * * * * * * * * * * * * *
Row 7 * * * * * * * * * * * * * * * * * * * *
Row 8 * * * * * * * * * * * * * * * * * * * *
Row 9 * * * * * * * * * * * * * * * * * * * *
Row 10 * * * * * * * * * * * * * * * * * * * *
Row 11 * * * * * * * * * * * * * * * * * * * *
Row 12 * * * * * * * * * * * * * * * * * * * *
Row 13 * * * * * * * * * * * * * * * * * * * *
Row 14 * * * * * * * * * * * * * * * * * * * *

Your program should have variables tracking the total number of tickets sold and the total revenue for all tickets sold.


Your program should allow the user to sell tickets one at a time. The user should be able to sell as many tickets as they would like (you need a loop for this). Do this with some sort of prompt or menu asking the user if they would like to sell another ticket. Don

Explanation / Answer

Your program must first initialize the array contents to properly display it in output.

I have just corrected that portion and added function init to initialize the array also your display function has 3 loops which is incorrect with two of them having variable named i. Your getSeat function and getPrice function is also totally wrong. I have not corrected those. The getPrice should get input and does not return anything because you are using arrays. Please try to correct those errors your self. In case you need any help post the questions.

#include <iostream>
#include <iomanip>

using namespace std;

//Use these constants as global variables
const int rows = 15;
const int Seateach = 20;
const char Open = '*';
const char Taken = '#';

void display(char Theatre [rows][Seateach]);
void getPrices(double price[], int ,int);
int getSeat(char Theatre []);

void init(char Theatre[rows][Seateach])
{
    for(int i=0;i<rows;i++)
        for(int j=0;j<Seateach;j++)
        Theatre[i][j]=Open;
}

int main ()
{
   
    char Theatre[rows][Seateach]={'*'};
    char Selection;
    init(Theatre);
    do
    {
        display(Theatre);
        cout << " MOVIE THEATER MENU "; // menu user decides
        cout << "------------------ ";
        cout << "1)Sell a ticket ";
        cout << "2)Quit program ";
        cout << "Please make a selection ";
        cin >> Selection;
        //cin.ignore();
        if(Selection == '1')
        {
        // getSeat(Theatre[ ], rows, Seateach );
        }
        else if(Selection == 'Q' || Selection == 'q')
        {
            cout << "You have choosen to quit the program ";
        }
        else if(Selection != 'Q' || Selection != '1' || Selection != 'q')
        {
            cout << "invalid Selection ";
        }
    }while(Selection != 'q' || Selection != 'Q' || Selection!=2);
    //system("PAUSE");
    return 0;
}


void display(char Theatre[rows][Seateach]) // function to display which seats are available
{
    int i,j;
    cout<<"seats:"<<endl;
    for(i=0; i < rows; i++)
    {
        cout<<"Row "<< setw(2)<<i;
        //cout << setw(3) << i << " ";
        for(j=0;j< Seateach;j++)
        {
           
            //for(j =0; j < Seateach; j++)
            //{
                cout << setw(3) << Theatre[i][j];
            //}
        }
        cout<<endl;
    }
}

/*function to Each row in the auditorium has a different ticket price.
* So tickets in row 0 may be 5.00 each and tickets in row 1 may be 10.00 each.
* Your program should have a FUNCTION that asks the user to enter a ticket price for each row.
* The price of tickets for each row should be stored in a one dimensional array.
*/
void getPrices(double price[], int rows, int Seateach)
{
    for(int count =0; count < rows; count++)
    {
        cout << "Please enter the price for each row ";
        cin >> price [count];
    }
    //return price[rows];

}
// This function is totally wrong please correct it.

// You have to check if seat number is free or not and return it.


int getSeat(char Theatre[15][20], int Seateach, int rows)
{
    int i, j;
    cout << "enter row ";
    cin >> i;
    cout << "enter seat ";
    cin >> j;
    return i;
}