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

Using C programming. Eclipse: I have the following code but I have run into some

ID: 3761364 • Letter: U

Question

Using C programming. Eclipse: I have the following code but I have run into some issues, first when it comes to the user inputting more than once seat I cannot make it show that multiple seats are taken and to output that _ number of seats have been taken at row __ and column __ and contine it until the number of seats selected have been chosen. I also want it the chart to update everytime a ticket(s) are purchased and give me the total ticket prices. It should keep track of the ticket sales, and the user should be given that option to see tht. Another thing is tht the program should give the user an option to see how many seats have been sold, seats available in each row, and seats available in the whole theater. to be more cleat I attached a picture of my instructions

void mapSeats (int i, int j, char sts[][30])

{

// char TAKEN = '*';

// char EMPTY = '#';

int rw = 15;

int col = 30;

printf (" Seats ");

fflush (stdout);

printf (" 012345678901234567890123456789");

fflush (stdout);

for (i = 0; i < rw; i = i + 1) {

printf (" Row %2d ", i);

fflush (stdout);

for (j = 0; j < col; j = j + 1) {

printf ("%c", sts[i][j]);

fflush (stdout);

}

}

putchar (' ');

}

void theatre (void)

{

int row = 15;

int column = 30;

float prices[15];

char sts[row][column];

char TAKEN = '*';

char EMPTY = '#';

int reserve;

int i = 0;

int j = 0;

int k=0;

// float cost;

// int static total;

printf ("Enter the price for each row of seats. ");

fflush (stdout);

for (row = 0; row < 15; row = row + 1) {

printf ("Row %2d: ", row);

fflush (stdout);

scanf ("%f", &prices[row]);

}

// printf("What would you like to do? Select a number: ");

// printf("1: Reserve seats");

// printf("2: View total ticket sales");

// printf("3: View sold and available seats");

for (i = 0; i < row; i = i + 1) {

for (j = 0; j < column; j = j + 1) {

sts[i][j] = EMPTY;

}

}

mapSeats (i, j, sts);

printf (" How many seats would you like to reserve? ");

fflush (stdout);

scanf ("%d", &reserve);

printf ("Enter the row and column number for the desired seat(s). ");

fflush (stdout);

for (k=1 ; k <= reserve; k=k+1) {

scanf ("%d %d", &row, &column);

printf (" You have selected Row %d, Column %d ", row, column);

fflush (stdout);

for (i = 0; i < 15; i = i + 1) {

for (j = 0; j <= 30; j = j + 1) {

if (row == i && column == j) {

sts[i][j] = TAKEN;

}

}

}

}

mapSeats (i, j, sts);

}

int main (void)

{

theatre ();

return 0;

}

Explanation / Answer

//A program that asks the user for input to buy theater seats.

#include <iostream>

#include <iomanip>

using namespace std;

//Function Declarations

int Show_Menu (); //To show main menu

void Show_Chart (); //To show seating chart

const char FULL = '*'; //Seat taken

const char EMPTY = '#'; //Seat open

const int rows = 15; //Number of rows

const int columns = 30; //Number of seats per row

char map [rows][columns]; //Array to hold seating chart

double price;

int total = 0;

int seat = 450;

int seat2 = 0;

int Quit = 1;

int main ()

{

const int Num_Rows = 15;

int price [Num_Rows];

int row2, column2, cost;

int answer;

//Main Logo

cout << " *********************************************************" << endl;

cout << " * *" << endl;

cout << " * Welcome to The our small town Theater *" << endl;

cout << " * *" << endl;

cout << " *********************************************************" << endl;

cout << endl << endl;

//Sets the row prices.

for (int count = 0; count < rows; count++)

{

cout << "Please enter the price for row " << (count + 1) << ": ";

cin >> price [count];

}

for (int i = 0; i < rows; i++)

{

for (int j = 0; j < columns; j++)

map [i][j] = EMPTY;

}

int choice;

do

{

choice = Show_Menu(); // Shows the main menu function.

switch (choice)

{

case 1:

cout << "View Seat Prices ";

for (int count = 0; count < rows; count++)

{

cout << "The price for row " << (count + 1) << ": ";

cout << price [count] << endl;

}

break;

case 2:

cout << "Purchase a Ticket ";

do

{

cout << "Please select the row you would like to sit in: ";

cin >> row2;

cout << "Please select the seat you would like to sit in: ";

cin >> column2;

if (map [row2] [column2] == '*')

{

cout << "Sorry that seat is sold-out, Please select a new seat.";

cout << endl;

}

else

{

cost = price [row2] + 0;

total = total + cost;

cout << "That ticket costs: " << cost << endl;

cout << "Confirm Purchase? Enter (1 = YES / 2 = NO)";

cin >> answer;

seat = seat - answer;

seat2 += answer;

if (answer == 1)

{

cout << "Your ticket purchase has been confirmed." << endl;

map [row2][column2] = FULL;

}

else if (answer == 2)

{

cout << "Would you like to look at another seat? (1 = YES / 2 = NO)";

cout << endl;

cin >> Quit;

}

cout << "Would you like to look at another seat?(1 = YES / 2 = NO)";

cin >> Quit;

}

}

while (Quit == 1);

break;

case 3:

cout << "View Available Seats ";

Show_Chart ();

break;

case 4:

cout << "View Seat Sales ";

break;

case 5:

cout << "quit ";

break;

default : cout << "Error input ";

}

} while (choice != 5);

return 0;

}

//********************************************************************************

//********************************************************************************

//** **

//** Define Functions. **

//** **

//********************************************************************************

//********************************************************************************

// Show Menu Function...

int Show_Menu()

{

int MenuChoice;

cout << endl << endl;

cout << " MAIN MENU ";

cout << " 1. View Seat Prices. ";

cout << " 2. Purchase a Ticket. ";

cout << " 3. View Available Seats. ";

cout << " 4. View Ticket Sales. ";

cout << " 5. Quit the program. ";

cout << "_____________________ ";

cout << "Please enter your choice: ";

cin >> MenuChoice;

cout << endl << endl;

return MenuChoice;

}

//Show Seating Chart Function

void Show_Chart ()

{

cout << " Seats" << endl;

cout << " 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 ";

for (int count = 0; count < 15; count++)

{

cout << endl << "Row " << (count + 1);

for (int count2 = 0; count2 < 30; count2++)

{

cout << " " << map [count] [count2];

}

}

cout << endl;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote