# c++ function help

This topic is 2994 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

This is gonna sound a little homework like because it's been given to me by a friend to increase my c++ skills. i'm working on a c++ console application and i'm writing a function for a model airline reservations. my function is suppose to produce a table of letters and rows. it will take values from a file they are the number of rows (12) and then how many seats per row (4) and then how many rows are upper class (4) and display them out using cout. the variables are already set, for this we'll call them varA, varB, and varC. There is an array already built, that holds max rows and max seats, however not sure how to make use of that or if i should even use that. across the top i'm suppose to read in the max seats (4) and set them to A B C D (an actual letter value) i can (char)i if i have a value of 65, 66, 67, 68 (A,B,C,D) then set the rows so it should like below. A B C D 1 2 3 4 (there is suppose to be a space here to clarify this is the upper class) 5 6 7 8 9 10 11 12 then it'll fill in with data and 0's i was thinking nested for loops, but all that really does is usually give me an endless loop. my current source i've been working with is below.
void displayPlane(int plane[][MAX_SEATS_PER_ROW], int numFirstClassRows,
int numRows, int seatsPerRow)
{
for (int row = 1; row < numRows; row++)
{
cout << setw(4) << row;
//for (int col = 1; col < seatsPerRow; col++)
//	cout << setw(2) << col;
}
//for (int firstClassRows = 1; firstClassRows < numFirstClassRows; firstClassRows++)
//{
//	cout << setw(2) << firstClassRows << endl;
//	storeRows = firstClassRows;
//}
cout << endl;
for (int coachClassRows = storeRows; coachClassRows < numRows; coachClassRows++)
cout << setw(2) << coachClassRows << endl;
}



##### Share on other sites
This must be part of a set of instructor homework excercises then since my Java professor assigned this exact problem not long ago!
2. (5 points) Write a Java class called SeatAssignment to assign passengers seats in an airplane. In
this program, you should assume that there’s a small airplane with seat numberings as follows. Note
that your class should provide a main() method so that the instructor can run your class without a
separate demo program.
1 AB CD
2 AB CD
3 AB CD
4 AB CD
5 AB CD
6 AB CD
7 AB CD
Your program should display the seat pattern, with an ‘X’ marking the seats already assigned. For
example, after seats 1A, 2B, and 4C are taken, the display should look like
etc...
I personally didn't see the point of it other than working with arrays and chars.
Of course you are going to use nested loops to work with the multiple dimensions so you just have to work through it.
Looks a lot harder than it really is.

##### Share on other sites
Nested loops is the most natural approach. If you're getting infinite loops, you've got a bug. Try this article.

1. 1
Rutin
19
2. 2
3. 3
4. 4
5. 5
frob
12

• 15
• 13
• 9
• 12
• 10
• ### Forum Statistics

• Total Topics
631442
• Total Posts
3000105
×