passing values from one function input into another function for searching

i am writing a program for my advanced c++ class. i am having trouble due to taking regular c++ two years ago because of transferring and changing majors to computer science.

my teacher requires our projects to be done with functions and no computing done in the main function but we use that to call all the other functions. i created one function that asks a user what row and seat they want(its for a theater.) it accepts the input and then the function ends. how can i create another function and call the input values into this other function to search for "availability". have a function that stores the seating as a 2 dimensional array where # indicates an available seat. is this possible to do in two functions or should i combine the two functions below is the code i have so far.


//Author: Steven Cortright
//Course: CSC 136
//Date: Spring 2013
//Purpose: Develop a program that will allow a theater to sell tickets for performances
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include <cstdlib>
#include <string>
#include <iostream>
#include "search.h"
#include <fstream>
using namespace std;

const int numSeats = 30;
const int numRows = 15;


//function prototypes
int menu();													//function to display menu
//void theaterPrices(float prices[]);
void availableSeating (char seating[numRows][numSeats]);	//function to display seating chart
void customerProcessing(int rowChoice, int seatChoice);						    //function to ask user what seat they want
void checkAvailability(char search[15][30]);



int main()
{
	
	char seats[15][30];
	int rowWanted = 0;
	int seatWanted = 0;
	float pricing[15];
	int choice = 0;
	choice = menu();
	switch (choice)
	{
	case 1:
			customerProcessing(rowWanted, seatWanted);
			break;
	case 2: 
			availableSeating(seats);
			break;
	case 3:
			cout << "You picked number 3.";
			break;
	case 4:
			cout << "You picked number 4.";
			break;

	}

}
int menu() //displays menu   WORKS
{
	int pick;
	cout << endl;
	cout << "1.  Process a Customer" << endl;
	cout << "2.  Print a seating chart" << endl;
	cout << "3.  Report total tickets sold and total price" << endl;
	cout << "4.  Quit" << endl;
	cout << "Choice:  ";
	cin >> pick;
	cout << endl;
	return pick;
}

/*void theaterPrices(float prices[]) //reads in seat prices
{
	ifstream infile; 
	infile.open("prices.txt");
	for(int i=0; i < 15; i++)
	{
		infile >> prices[i];
	}
	
	for (int j = 0; j<15; j++)
	{
		cout << prices[j];
	}
	infile.close();
}
*/

void availableSeating (char seating[numRows][numSeats])  //displays current seating chart  WORKS
{
	cout << "            Seats" << endl;
	cout << "123456789012345678901234567890" << endl;
	
	char input = '#';
	for(int row = 0; row < 15; row ++)
	{
		for (int col = 0; col < 30; col ++)
		{
			seating[row][col] = input;
		}
	}
	
	for(int row = 0; row < 15; row ++)
	{
		cout << "Row ";
		for (int col = 0; col < 30; col ++)
		{
			cout << seating[row][col];
		}
		cout << endl;
	}
}

void customerProcessing(int rowChoice, int seatChoice)
{
	int seatSelection;
	int rowSelection;
	cout << "Enter the row and set you want: ";
	cin >> rowSelection >>  seatSelection;
}
Topic archived. No new replies allowed.