Hi everyone, I'm having a bit of trouble finishing up this movie theater sales program. I've made it this far and I'm stuck on how to display my updated seat map for the theater once the "user" has sold some seats.
"Seats that are taken should be represented by a # symbol and seats that are available should be represented by a * symbol. The first thing your program should do is initialize all of the seats to available (*) and display the seating chart.(HINT: The seating chart should be a two dimensional array.) Below is an example of the seating chart with all seats initialized to available."
Also, the second thing I'm having trouble with is how to figure out and display the total tickets sold and total revenue from the tickets. I'd greatly appreciate any help at this point.
You may want to consider defining your constants as global variables, since you're using them in multiple functions and they don't change.
Additionally, from a user standpoint, no one would enter a seat into a program as the seat number - 1. People don't think in array subscript notation. A better interface design be to require them to enter a valid seat between 1 and the rownum and colnum, and then subtract 1 from that when determining which array subscript to update.
You're over-complicating displaying the seat map. You have an array that has been initialized to all empty seats, and your main function updates the seats to # values when a seat is sold. All you need to do is display the array as it currently exists in row x col format. I'm also not clear on why you're only displaying 10 at a time - just display the 15 x 20 array, unless there's a reason you haven't communicated.
To get total tickets sold and revenue, just use a running total/accumulator. Each time you sell a ticket, increment a counter by 1. The counter at any time will reflect the number of tickets sold, and from the tickets sold you can get the revenue. If you've not used a running total/accumulator before, some basic Google searching will get you up to speed.
In regard to using globals for my const variables, I forgot to mention, but our professor has specifically instructed us: "IMPORTANT NOTE: Make sure and use the required functions as indicated in the instructions for this program! NO GLOBALS -no exceptions."
Additionally, from a user standpoint, no one would enter a seat into a program as the seat number - 1. People don't think in array subscript notation. A better interface design be to require them to enter a valid seat between 1 and the rownum and colnum, and then subtract 1 from that when determining which array subscript to update.
I concur with what you're saying, but I'm just trying to follow the required output. I would definitely do things differently if this was a personal program I was creating.
As for displaying the seat map array in two portions, I did so to match the required output on Hypergrade. Without it, my "*" and spacing for number display will not line up.
I'm going to try and work on some changes including what you've mentioned, thank you.
EDIT: I've updated this post with the professor's instructions for further clarification.
Step 1: The program should have a FUNCTION that displays a screen that shows which seats are available and which are taken. Seats that are taken should be represented by a # symbol and seats that are available should be represented by a * symbol. The first thing your program should do is initialize all of the seats to available (*) and display the seating chart. (HINT: The seating chart should be a two dimensional array.)
Step 2: 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.
Step 3: Your program should have variables tracking the total number of tickets sold and the total revenue for all tickets sold.
Step 4: 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't forget to validate input data if you need to.
To allow the user to sell a ticket your program should have the user enter a row number and a seat number for the ticket they would like to sell. The program should do four things with this information:
It should check to see if the seat is available. If the seat is taken the program should not allow the user to sell the ticket. If this happens, print a message to the user saying the ticket is not available and prompt the user to see if they would like to sell another ticket.
If the seat is available the program should update the seating chart by putting a taken symbol (#) in that seat's position in the chart.
The program should then look up the row price for the seat sold. Your program should have a variable tracking the total revenue, the price of the seat sold should be added to this total after each sale.
Your program should have a variable tracking the total tickets sold. The next thing your program should do when selling a ticket is update the total tickets sold.
Step 5: Once the user is finished selling tickets print out an updated seating chart followed by the total tickets sold and the total revenue generate from those tickets.
NOTE: You are required to use two arrays in this program, one for the seating chart and one to store the prices for each row. You are also required to use two functions: one to display the seating chart and one to read in the price per row data and store it in the array with the prices for each row in it. You may use other functions if you want to but they are not required.
mastakhan has made some good points. A user will be thinking in terms of 1 - 20 or 1 - 15 for making a seat choice. It is up to the programmer to think in terms the arrays and what the user inputs.
Before I saw the requirements of the program I have been working things differently and need to change some things back.
For displaying the seating map I left what you started and wrote another function to display the "seatsMap" array. Take a look and see what ideas it might give you:
I hope I did not mislead you into completely changing your program. This new version may work, but I have not tested it yet. One of the first things I noticed is lines 5 and 6 are two global variables that you are not allowed to use. The second thing I noticed is that you have made it more complicated than it need to be.
There is very little wrong with your original code. I added two variables "seatCount" and "totalRevune" along with a bool and char variables I used in a do/while loop in "if (selection == '1')" in main. In the last if/else in the else part I dealt with adding to "totalRevnue" and "seatCount". The last part of the do/while loop prompt the user to continue entering seat choices or exit.
Two reasons I added the "ShowMap" function I wrote was 1. to preserve what you have and 2. to have a more generic function without rewriting your original code.
I will have to work on your new code tomorrow morning and see how it works.