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

There are examples but none of them show how to read the numbers from an input f

ID: 3746461 • Letter: T

Question

There are examples but none of them show how to read the numbers from an input file

I am stuck on the menu functions.

I am doing this program in c++

View current seats with the - and *

Refunding ticket

Saving the data file

5 19

6 16

11 30

9 29

15 26

10 29

7 18

13 25

3 12

9 2

4 11

10 24

5 23

13 10

15 5

12 19

11 17

5 24

5 23

8 19

14 27

5 18

6 22

13 27

1 15

5 21

15 8

4 28

8 23

11 4

2 12

4 7

6 28

15 21

9 18

4 3

6 15

2 19

4 11

11 11

3 1

2 14

8 8

13 12

4 13

9 11

14 27

10 11

15 24

Verizon 2:25 PM × CSCI 3000 Homework 2.docx Write a program that can be used by a small theater to sell tickets for performances. The theater's auditorium has 15 rows of seats, with 30 seats in each row. The program should display a screen that shows which seats are available and which are taken. For example, the following screen shows a chart depicting each seat in the theater. Seats that are taken are represented by a # symbol, and seats that are available are represented by a symbol: You will read the input file "tickets.txt" to read the initial condition of the theater. In the file, cach line will represent one seat by a row and column number. For instance, if the file content is as follows: 10 15 5 20 8 13 This means three tickets were sold. And the seat location of the first ticket is 10t row and 15h column. The location of the second seat is 5th row and 20th column. And the location of the third seat is 8th row and 13th column. Your program starts with showing a menu to the user. In the menu there will be 5 options as follows: 1. View Current Seats a. This menu will show the current seat conditions as shown in the above figure. 2. Sell Ticket a. Program will ask user the row and column number of the seat. And will mark that seat as sold. (Also, provide a warning message if the seat was already sold) 3. Refund Ticket a. It will ask user to enter row and column number. If the seat was sold, it will mark it unsold. (Also, provide a EOpen With Print

Explanation / Answer

//Hey! Here is your solution

//If you find it useful, please do upvote. Thank you

// Code is tested and works perfectly in visual studio 2015.

// As requested, Giving you the code to read ticket.txt file and showing current seats in theatre.

// If you need help with rest, please comment.

#include <iostream>

#include <fstream>

using namespace std;

void main() {

ifstream fin;

char seats[16][31];

int x;

// Note : You have to give full path of ticket.txt file here.

fin.open("ticket.txt", ios::in);

char my_character;

bool flagTime = true, flagSeat;

int number = 0;

int i = 1,j,choice;

//Creating empty theatre

for (int row = 1; row <= 15; row++)

{

for (int col = 1; col <= 30; col++)

{

seats[row][col] = '-';

}

}

cout << "Select option from below - 1. View Current Seats 2. Sell Ticket 3. Refund Ticket 4. Save Data File 5. Exit Program Your Choice - ";

cin >> choice;

i = 0;

j = 0;

flagSeat = false;

switch (choice)

{

case 1:

//showing current seats allocation

while (!fin.eof())

{

//loading data from text file

fin.get(my_character);

if ((int)my_character == 10)

{

seats[i][j] = '#';

fin.get(my_character);

flagSeat = false;

// cout << " i = " << i << " j = " << j;

i = 0;

j = 0;

}

else

{

if ((int)my_character == 32)

flagSeat = true;

else

{

if (flagSeat == false)

i = i * 10 + (int)my_character - 48;

else

j = j * 10 + (int)my_character - 48;

}//else

}//else

}//while

//showing allocation

cout << " ";

for (int row = 1; row <= 15; row++)

{

for (int col = 1; col <= 30; col++)

{

cout << seats[row][col] << " ";

}

cout << " ";

}//for

}//switch

cout << " Press any key to continue";

cin >> x;

}