the question is to be solved using loops,decisions and arrays!!
QUESTION:
Statement of question:
“AIRLINE RESERVATION"
Write a program to assign seats on a 10-seater plane. Your program should first ask a user to enter 1 for First Class and 2 for Economy class. First 5 seats are economy and last 5 seats are first class. Whenever a seat is reserved the program should display output that which seat ( from 1 to 10) was occupied and in which class.
USE A SINGLE SCPRITED ARRAY TO REPRESENT THE SEATING CHART. INITITALISE ALL ELEMETS TO 0 TO INDICATE THE SEATS ARE EMPTY AND WHEN RESERVED ASSIGN SEAT NUMBER TO 1.
Your program should never assign same seat twice!!!!
If first or economy class is full then your program should suggest the user the other class.
If both classes are full then your program should inform user that flight is full and suggest him to try on next flight.
now pls point out errors in my program one by one
#include <iostream.h>
#include <conio.h>
int main()
{
int arr[10]={0,0,0,0,0,0,0,0,0,0};
int a,i;
do{
cout<<"\nPlease Enter 1 for 'First Class' or 2 for 'Economy Class':";
cin>>a;
if ( a==1)
for ( i=0 ; i<=4 ; i++ )
{
if ( arr[i]== 0)
{arr[i]=1;
break;}
}
else if ( a==2)
for ( i=5 ; i<=9 ; i++)
{
if ( arr[i]==0)
{arr[i]=1;
break;}
}
else
cout<<"Input error!"<<endl;
for ( i=1 ; i<=10 ; i++)
cout<<arr[i]<<" ";
} while
(arr[0]+arr[1]+arr[2]+arr[3]+arr[4]+arr[5]+arr[6]+arr[7]+arr[8]+arr[9]!=10);
getch();
return 0;}