-1

. 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”.

5
Contributors
7
Replies
8
Views
5 Years
Discussion Span
Last Post by Narue
Featured Replies
  • [B]char answer='Y'/'N';[/B] That says that the char [B]answer [/B]is the char [B]Y[/B] divided by the char [B]N[/B]. 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. Read More

0
#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;
	
	
}

Edited by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

1

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.

Comments
It is "Make Your Own Syntax" day, didn't you get the memo?
-1

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

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

Edited by cmccaig: n/a

0

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.