Hello i am trying to write a programm for my college c++ class. This class is the second level and i took the first level two years ago due to just transferring to different school/major. My project is to write a program for a small theater that will show what seats are available and compute ticket purchases. I am having trouble with arrays and functions. In my code below, i was able to write a menu function and have it displayed. That works. I then wrote a function that makes all the values of the 2 dimensional array(seating chart) a "a". Then the function displays the 2 dimensional array to the screen. I wrote this code in a seperate program in the main function to see if it worked. When it runs, it displays all the "a"'s but it does accross the whole screen instead of in a 15 row 30 column chart. My second problem, is im not very familier with functions. I cant get the function to display the chart (even if the chart displays wrong) to display when the user inputs the number 2. Really need help. Once i have it explained and shown to me i will understand it better.
//Author: Steven Cortright
//Course: CSC 136
//Date: Spring 2013
//Purpose: Develop a program that will allow a theater to sell tickets for performances
For your first problem, add a cout << endl; statement after your inner for loop while outputting the array.
For your second problem, you're not passing anything in to the availableSeating(...) function. You need to make an array in main, and then populate it (by moving the first set of for loops in your availableSeating(...) function to main).
First of all: Where you DECLARE array for seating (in search.h?)? What kind of array that would be? [bool would be nice (true=free seat, false = preserved seat)]
After you fixed that: (printing seats)
pseudo code:
1 2 3 4 5 6
for each line of seats:
for each column of seats:
print out current seat // reserved/free
end
endline
end
look closely on availableSeating()-function. Each time you enter there you make sure that all "seating[][]" cells are set to 'a'. After that you print all the a's.
it worked lol. i realize now why it wouldn;t work with have the endl where i had it. Having it outside like that allows the loop to run through for each row and then return instead of returning after every element. thank you for the help