//function declaration
void menu(void); //Menu function used in the program
void ticket(int); //Booking Ticket function
void seats(void); //Assigning Seat function
//Declaration of data types used in the program
int seat[20]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},option; //Seats
int bsns_cls=0, economy_clas=5;
int flght_no,gate_no,j, dis , selopt1; //Flight number,gate number, another used variabes
char customer_nm[20][20]; //Customer Name
char dstnce [1][20];
int age[20];
//int ag[15];
int g,k,t,f;
int h=0,q=5; //Destination
void main()
{
clrscr();
for(j=0;j<20;j++)
{
strcpy(customer_nm[j],"Not Assigned");
}
/* printf("\n\n\t\tWelcome to GO AIR'S seat Reservation System\n");
printf("\n\t\t\tPlease Enter Flight No.: ");
scanf("%d",&flght_no);
printf("\n\t\t\tEnter Destination Place: ");
scanf("%s",dstnce);
printf("\n\t\t\tEnter Gate Number: ");
scanf("%d",&gate_no);*/
menu(); //function call
getch();
}
void menu() //function defined
{
clrscr();
printf("\n\n\t\tWelcome to GO AIR's Reservation System\n\n");
printf("\n\t\t\t1. Assign Seat\n ");
printf("\n\t\t\t2. Search Boarding Pass\n ");
printf("\n\t\t\t3. Display all seats information\n ");
printf("\n\t\t\t4. Exit from the system \n");
printf("\n\n\t\t\tEnter Your Choice: ");
scanf("%d",&option);
switch(option) //use of conditional statements
{
case 1:
clrscr();
printf("\n\t\tADD SEAT\n");
printf("\n\t\t1. Business Class");
printf("\n\t\t2. Economy Class");
printf("\n\t\t3. Main Menu");
printf("\n\n\t\tEnter Your Choice: ");
scanf("%d",&selopt1);
ticket(selopt1);
getch();
break;
case 2:
seats();
break;
case 3:
clrscr();
printf("\n\n\n\n\n\t\t******* Flight Information *******");
printf("\n\n\t\tName\t\tAge\t\tSeat Number\n");
for(dis=0; dis<20;dis++)
{
printf("\n\n\t\t%s\t%d\t%d",customer_nm[dis],age[dis],seat[dis]);
}
getch();
menu();
break;
case 4:
printf("\n\n\t\tThank You for using this system");
printf("\n\t\t Press any key to continue...");
getch();
exit(0);
break;
default :
printf("!! Please Enter valid menu Option");
getch();
menu(); //function call
}
}
void ticket(int selopt1) //function defined
{
switch(selopt1)
{
case 1:
if(seat[bsns_cls]<6)
{
printf("\n\t\tEnter Customer's Name: ");
scanf("%s",customer_nm[bsns_cls]);
printf("\n\t\tEnter Customer's Age: ");
for(g=h;g<=h;g++)
{
scanf("%d",&age[g]);
}
h=g;
printf("\n\t\t
Your seat has been confirmed.\n\t\tName\tAge\tSeatNo.\n\t\t%s\t%d\t%d
",customer_nm[bsns_cls],age[g-1],seat[bsns_cls]);
bsns_cls++;
getch();
menu();
}
else
{
printf("\n\t\tBusiness class is full.");
if(economy_clas <= 20)
{
printf("\n\t\tWould you like to go by Econnomic class.");
getch();
menu();
}
else
{
printf("\n\t\t Business class is also full.\n\n");
printf("\t\t Please wait while new flight arrives");
}
}
break;
case 2:
if(seat[economy_clas]<=20)
{
printf("\n\t\tEnter Name: ");
scanf("%s",customer_nm[economy_clas]);
printf("\n\t\tEnter Age: ");
for(k=q;k<=q;k++)
{
scanf("%d",&age[k]);
}
q=k;
printf("\n\t\tYour seat has been confirmed.\n\t\tName\tAge\tSeatNo
age[k-1],seat[economy_clas]);
// printf("\n\t\tSeat has been [economy_class]\n\t\tYour seat has beenconfirmed.\n\t\tName\tAge\tSeatNo.\n\t\t%s\t%d\t%d",customer_nm[bsns_cls],age,seat[bsns_cls]]);
printf("\n\t\tYour seat has been confirmed.\n\t\tName\tAge\tSeatNo .\n\t\t%s\t%d\t%d",customer_nm[bsns_cls],age,seat[bsns_cls]);
economy_clas++;
getch();
menu();
}
else
{
printf("\n\t\tSorry Economy class is full.");
if(bsns_cls < 6)
{
printf("\n\t\tWould you like to go by Business class.");
getch();
menu();
}
else
{
printf("\n\t\tSorry Business class is also full.\n\n");
printf("\t\t Wait for the next flight to arrive");
}
}
break;
case 3:
menu();
break;
default:
printf("\n\t\t!!Please enter valid menu option.....");
getch();
menu();
}
}
void seats()
{
printf("\n\t\tEnter Seat Number: ");
dis=0;
scanf("%d",&dis);
// t=dis;
if(dis<6)
{
// t=dis;
dis--;
clrscr();
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t******** Boarding Card Details *****");
// printf("\n\n\t\t\tName");
printf("\n\n\t\tName:\t\tAge\t\tSeatNo.\n\n\t\t%s\t\t%d\t\t%d",customer_nm[dis],age[dis],seat[dis]);
printf("\n\n\t\t******** HAPPY JOURNEY TO U ********");
getch();
menu();
}
if(dis>5)
{
// f=dis;
dis--;
clrscr();
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t******** Boarding Card Details *****");
// printf("\n\n\t\t\tName")
printf("\n\n\t\tName:\t\tAge\t\tSeatNo\n\n\t\t%s\t\t%d\t\t%dcustomer_nm[dis],age[dis],seat[dis]);
printf("\n\n\t\t******** HAPPY JOURNEY TO U ********");
getch();
menu();
}
// dis--;
// clrscr();
// printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t******** Boarding Card Details *****");
// printf("\n\n\t\t\tName");
// printf("\n\n\t\tName: \t\tAge\t\tSeatNo.\n\n\t\t%s\t\t%d\t\t%d",customer_nm[dis],age[dis+1],seat[dis]);
//printf("\n\n\t\t******** HAPPY JOURNEY TO U ********");
// getch();
//menu();
}