Ask Computer Engineering Expert

Assignment

Write a program that can be used by a concert hall to sell tickets for performances. The auditorium has 15 rows of seats, with 30 seats in each row. Use a 2D-array to represent each seat in the auditorium. Seats that are taken are represented by an * symbol, and seats that are available are represented by a # symbol. For example, the following diagram shows the availability of each seat in the auditorium:

Seats

123456789012345678901234567890
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 ##############################
Row 15 ##############################

All the seats in the same row will have the same cost. However, each row will have a different cost. The cost of the rows will be stored in a separate 1D-array. Note, the 2D seats array and the row costs array should be parallel arrays. In other words, the cost in element jof the row costs array should represent the cost of the seats in row j of the 2D seats array.

The costs of the rows are stored in a .txt file: row_costs.txt. This file has been provided by me (see the resources section at the bottom). The first value in the file is the cost of the first row, the second value in the file is the cost of the second row, and so on.

Your program will save the availability of the seats in the text file: auditorium.txt, upon exiting.This will allow the status of the seats to persist between program runs. Each time the program runs, the seat availability will change due to seats being sold. This file consists of 15 lines, each with 30 symbols (* or #). Each line represents the seat availability for one row of the auditorium. I have provided you with a file (see the resources section at the bottom),in which all 15 lines have been marked with a #symbol to indicate that every seat is available. Use this file to run the program for the first time.Before the program exits, the contents of the auditorium.txt file will be overwritten with the current seat availability.

When the program starts, it must ask the user to provide the names of both files (don't hardcode the names of the files in the source code even though you know the names ahead of time). The program should continue to prompt the user for these files, until both files are valid.The program must then read row_costs.txtand auditorium.txt. The cost of the rows should be stored in the row costs array, and the status of each seat (taken or available) in the 2D seats array. Both files should be closed after they have been read.

After the files have been read, the program should display the following menu:

Concert Hall Seating

1. Sell Ticket
2. See Total Number of Seats Available
3. See Rows with Available Seats
4. See Rows with a Specific Seat # Available
5. See Total Ticket Sales
6. Exit

Enter Choice:

If choice 1 is selected, the seating chart should be displayed -just like the diagram above- and then the user should be prompted for the row (1-15) and seat (1-30) numbers of the seat to be sold. The user must continue to enter a seat until it's valid and available.After the ticket is sold, the 2D seats array must be updated, the cost of the seat soldshould be displayed, and the menu redisplayed (don't worry about clearing the screen). If all the seats have been sold out, the program should display "Sorry. All the seats are sold out!", and not allow a seat to be sold.

If choice 2 is selected, the total number of seats available should be displayed on the screen and the menu redisplayed.

If choice 3 is selected, only the row numbers of the rows with available seats should be displayed on the screen and the menu redisplayed.

If choice 4 is selected, the user should be prompted for a seat # (1-30). The user must continue to enter a seat # until it's valid.Then the row numbers of only the rows that have that seat # available should be displayed. The menu should then be redisplayed.

If choice 5 is selected, the total ticket sales should be displayed and then the menu redisplayed. To find the total sales add the costs of all the seats that have been sold. (Note: This total doesn't refer to only the seats sold during a specific program run.)

If choice 6 is selected, the program should exit. However, before the program exits, it should save the current seat availability -stored in the 2D seats array- in auditorium.txt. The user doesn't need to specify the file name again, since it was provided at the beginning.

Note: The user must continue to enter a menu choice until it's valid.

Implementation Details:

You must implement a class called Auditorium. This class should contain the following fields and methods, as a minimum requirement. You may add additional fields and methods to this class.

• A private 2D-array field to store the seat availability.

• A private array field to store the row costs.

• An appropriate constructor. The constructor should be passed the arrays containing the row costs, and the availability of the seats.

• A public method which returns the number of rows in the auditorium.

• A public method which returns the number of seats in the rows of the auditorium.

• A public method that displays the seating chart.

• A public method which updates the availability of a seat in the 2D seats array after it is sold. A seat is identified by specifying a row number (1-15) and a seat number (1-30).

• A public method which returns true if a seat is available, or false if the seat has been sold.

• A public method which returns true if all the seats have been sold, otherwise false.

• A public method which returns the cost of a seat.

• A public method which returns the total number of seats available.

• A public method which returns the number of seats available in a specific row.

• A public method which returns true if a row has a specific seat number (1-30) available, or false if it doesn't.

• A public method which returns the total ticket sales.

• A public method which writes the contents of the 2D seats array to the appropriate file. This method should be passed a PrintWriter object associated with the file in which the data will be saved.

In addition, you must implement a main class (driver)in a separate source file. The driver must create an instance of the Auditorium class and invoke its methods, to keep track of the seats that have been sold and help perform the menu actions.

Besides the main() method, the main class should contain the following methods, as a minimum requirement. You may add additional methods to this class.

• A method to display the menu.

• Methods to open and read both files. After the files are read, and the data is stored in appropriate localarrays, the arrays should be passed to the constructor of the Auditorium class.

• Methods to process each of the menu actions.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92745578

Have any Question?


Related Questions in Computer Engineering

Does bmw have a guided missile corporate culture and

Does BMW have a guided missile corporate culture, and incubator corporate culture, a family corporate culture, or an Eiffel tower corporate culture?

Rebecca borrows 10000 at 18 compounded annually she pays

Rebecca borrows $10,000 at 18% compounded annually. She pays off the loan over a 5-year period with annual payments, starting at year 1. Each successive payment is $700 greater than the previous payment. (a) How much was ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Suppose you make 30 annual investments in a fund that pays

Suppose you make 30 annual investments in a fund that pays 6% compounded annually. If your first deposit is $7,500 and each successive deposit is 6% greater than the preceding deposit, how much will be in the fund immedi ...

Question -under what circumstances is it ethical if ever to

Question :- Under what circumstances is it ethical, if ever, to use consumer information in marketing research? Explain why you consider it ethical or unethical.

What are the differences between four types of economics

What are the differences between four types of economics evaluations and their differences with other two (budget impact analysis (BIA) and cost of illness (COI) studies)?

What type of economic system does norway have explain some

What type of economic system does Norway have? Explain some of the benefits of this system to the country and some of the drawbacks,

Among the who imf and wto which of these governmental

Among the WHO, IMF, and WTO, which of these governmental institutions do you feel has most profoundly shaped healthcare outcomes in low-income countries and why? Please support your reasons with examples and research/doc ...

A real estate developer will build two different types of

A real estate developer will build two different types of apartments in a residential area: one- bedroom apartments and two-bedroom apartments. In addition, the developer will build either a swimming pool or a tennis cou ...

Question what some of the reasons that evolutionary models

Question : What some of the reasons that evolutionary models are considered by many to be the best approach to software development. The response must be typed, single spaced, must be in times new roman font (size 12) an ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As