Ethan O.

asked • 01/30/20

Please!!!! help me write this program (Do not hold the auditorium in memory. Utilize random file access to view and modify the auditorium)

Adult - $10

Child - $5

Senior - $7.50


Sample Theatre

ABCDEFGHIJKLMNOPQRST
1 ...AA..CSSAC........
2 ACSAACCA....AAAA..SS
3 .........AS.........
4 C.A.S.A.S.C.S.C.A.A.
5 AACACSSA.CCSSS.AAACC

If user wants to reserve seats, display the current
seating availability for that auditorium.

ABCDEFGHIJKLMNOPQRST
1 ...##..#####........
2 ########....####..##
3 .........##.........
4 #.#.#.#.#.#.#.#.#.#.
5 ########.#####.#####


Do not hold the auditorium in memory

  1. Utilize random file access to view and modify the auditorium


Input validation


Parameter: input string


Return: Boolean

  1. Parse string character by character
  2. If invalid character, return false
  3. Return True

Best Available


Parameter: row, total quantity


Return: starting seat


  1. Open file
  2. For 1 to N-x+1 (N = number seat in a row, X = total number of tickets)
  3. For 1 to total quantity
  4. Read character
  5. If character != period
  6. Break
  7. If loop ends and all seats checked are empty
  8. calculate distance
  9. (outer loop counter + (total quantity-1)/2 - (N+1)/2
  10. Keep smallest distance and starting seat number
  11. Close file
  12. Return starting seat number
  13. -1 if no best seats available

Display Auditorium


Parameter: none


Return: nothing


  1. Open file
  2. display column header
  3. While not EOF
  4. Read lines
  5. Display row number
  6. Display line
  7. change character to #
  8. close file

Reserve Seats


Parameter: row, seat, adult quantity, senior quantity, child quantity


Return: nothing


  1. Open file
  2. Move file pointer to proper row
  3. Move file pointer to proper character (seat)
  4. For each ticket type
  5. For 1 to quantity
  6. Write appropriate letter to file
  7. Close file

Check Availability


Parameter: row, seat, total quantity


Return: Boolean


  1. Open file
  2. Move file pointer to proper row
  3. Move file pointer to proper character (seat)
  4. For 1 to quantity
  5. Read character
  6. If character is not a period
  7. Close file
  8. Return false
  9. Close file
  10. Return true

Display Report


Parameter: none


Returns: nothing


  1. Open file
  2. While not EOF
  3. Read character
  4. Increment appropriate counter on character read
  5. A = adult, S = senior, C = child, period = empty
  6. Print report
  7. Total seats
  8. Total sold
  9. Adult Sold
  10. Child sold
  11. Senior sold
  12. Total sales
  13. Close file

Main

  1. Loop (do...while not exit)
  2. Print main menu
  3. Get user input
  4. If user does not want to exit
  5. Display auditorium
  6. Ask user for row, seat and quantities (adult, child, senior)
  7. Validate input for each input
  8. Loop if not valid
  9. Check if seats are available
  10. If available reserve seats
  11. If seats not available
  12. Find best available seats
  13. Ask user to reserve best available ( if found)
  14. If user accepts
  15. Reserve seats
  16. Print Report


Patrick B.

I would keep 3 files: (1) the main binary file that holds the auditorium data , a 2 x 2 array of characters O,S,A,C (2) an index file which contains the prices, # of rows,and # of seats per row (3) a file which contains the sales statistics; the files are kept in-sync using a primary key called the AUDITORIUM ID #; THIS is the proper database design, and the requirements of this assignment are asking for it
Report

02/08/20

1 Expert Answer

By:

Patrick B. answered • 02/08/20

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.