Use firstClass and and economy to calculate indexes into the array of seats which represent the first available seat in each section. Here's something that might guide you.
if(sections == 1) //customer wants first class
{
if(firstClass < 5)/*there's only 5 seats in first class, they are seats[0], seats[1], seats[2], seats[3], and seats[4]*/
cout << "you will be assigned seat " << seats[firstClass];
/*now there's one less seat class in first class
so increment firstClass so you don't give the seat out twice*/
++firstClass;
}
if(sections == 2) //they want economy.
/*the first open seat in economy will be at index i == 5 + economy. You can write the code notifying the customer what seat they were assigned and keeping track of the next available seat in economy */
Last edited by Lerner; Nov 12th, 2007 at 2:58 pm.
Reputation Points: 718
Solved Threads: 373
Nearly a Posting Maven
Offline 2,253 posts
since Jul 2005