. A small airline has just purchased a computer for its new automated reservation systems. You have been asked to program the new system. You are to write a program to assign seats on each flight of the airline’s only plane (capacity: 10 seats)

Your program should display the following menu of alternatives

Please type 1 for “side”
Please type 2 for “centre”

If the person types 1 your program should assign seats (1-5).
If the person types 2 your program should assign seats (6-10)

Your program should print a boarding pass indicating the person’s seat number and whether it is in the side or middle section of the plane.

Use single subscripted array to represent the seating chart of the plane. Initialize all elements to 0 to indicate that all seats are empty. As each seat is assigned set the corresponding elements of the array to 1 to indicate that seat is no longer available

Your program should off course never assign a seat that has already been assigned. If no seats available print the message “Next flight leaves in 3 hours”.

Recommended Answers

All 7 Replies

Show us the code you already have and which part you're having trouble with.

#include<iostream>
#include<string>

using namespace std;

void printSeats(int[]);

int main() 

{
	int seats[11] = {0};
	int input;
	int side = 6,centre=1;
	int passenger=0;
	char answer='Y'/'N';


	while(passenger < 10)
	{

		cout<<"Please type 1 for 'side'\n"
			<<"Please type 2 for 'center'\n"
			<<"Your Choice ";
		cin>>input;

		
		
		if (input == 1 || input == 2){
			if(seats[0]==1 && seats[1]==1 && seats[2]==1 && seats[3]==1 && seats[4]==1 && seats[5]==1 && seats[6]==1&& seats[7]==1 && seats[8]==1 && seats[9]==1)
				cout<<"This Flight is FULL!"
				<<"The Next Flight leaves  in 3 hours\n\n";
			
		}
		
		 if (input == 1 ){
			
			if (side<=10){
				cout<<"\nYou Have Chosen side seats "<<side<<endl;
				seats[side++];
				++passenger; }
				
				if(side>10)	  
				    cout<<"\nThe Side Seats is Full "<<endl;
					
	
		 }		
	
		 if(input == 2 ){
				
			if(centre<=5)
				cout<<"\nYou Have Chosen centre seats "<<centre<<endl;
				seats[centre++];
				++passenger;
						

				if(centre> 5)
					 cout<<"\nThe Centre Seats is Full"<<endl;
		 }

	
		}
	
	
		 
		 system("pause");
		 return 0;
	
	
}

Are u posting your assignment for we to solve?

yup but not assignment juzt only tutorial...i have to solve it problem...

char answer='Y'/'N';

That says that the char answer is the char Y divided by the char N. I doubt you meant that. You need to go back to the basics of what a char type is and how you set a value.

commented: It is "Make Your Own Syntax" day, didn't you get the memo? +14

he may of meant
char answer= '\'Y\'\'N\'';

^ something like that
so that when its printed to console its separated by '

he may of meant
char answer= '\'Y\'\'N\'';

^ something like that
so that when its printed to console its separated by '

And what character would that represent?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.