airline reservation in c code using linkedlist stack queue
#1

need a c progrm for airline reservation using linked list and queue concept
Reply
#2
(21-11-2012, 08:02 PM)Guest Wrote: need a c progrm for airline reservation using linked list and queue concept

Reply
#3

airline reservation in c code using linkedlist stack queue

#include<stdio.h>
#include<ctype.h>

#define MAX_NUM_SEATS (20)
#define MAX_NUM_SEATS_IN_FIRST_CLASS (5)
#define MAX_NUM_SEATS_IN_ECONOMY (MAX_NUM_SEATS - MAX_NUM_SEATS_IN_FIRST_CLASS)

int main()
{
int plane[MAX_NUM_SEATS] = {0}, i=0;
int nNumSeatsInFirst = 0;
int nNumSeatsInEconomy = 0;
int nSeatAssignmentFirstClass = 1; // start at 1;
int nSeatAssignmentEconomy = MAX_NUM_SEATS_IN_FIRST_CLASS + 1; // start at 6
int choice;
int nClass;
int nCurrentSeatAssignment;// firstClass=1,economy=6,choice;
char response[2];
char firstname[35], lastname[35];
int bPrintTicket;

while( i < MAX_NUM_SEATS )
{
printf("\n%s\n%s\n", "Please type 1 for \"First class\"","Please type 2 for\"Economy\"");
scanf("%d", &choice);

if( !( ( 1 == choice ) || ( 2 == choice ) ) )
{
continue;
}

// start out assuming we will print ticket!
bPrintTicket = 1;

printf("\nEnter first name:");
scanf("%s",firstname);

printf("\nEnter lastname :");
scanf("%s", lastname);

nClass = choice; // store the class before doing all the logical checks

/****************************************************************/
/*************** ECONOMY SECTION ***************/
/****************************************************************/
if( 2 == choice )
{
// check for economy full
if( nNumSeatsInEconomy >= MAX_NUM_SEATS_IN_ECONOMY )
{
// economy full
// check for first class (plane ) full
if( nNumSeatsInFirst <= MAX_NUM_SEATS_IN_FIRST_CLASS )
{
printf("The economy section is full.\n");
printf("would you like to sit in first class ");
printf("section( Y or N)?");
scanf("%s", response);

if ( toupper(response[0])=='Y')
{
// print ticket!
bPrintTicket = 1;
printf( "Your seat assignment is %d\n", nSeatAssignmentFirstClass );
nCurrentSeatAssignment = nSeatAssignmentFirstClass;
plane[nSeatAssignmentFirstClass - 1] = 1;
nSeatAssignmentFirstClass++;
nNumSeatsInFirst++;
nClass = 1;
i++;
}
else
{
// don't print ticket!
bPrintTicket = 0;
printf("Next flight leaves in 3 hours.\n");
}
}
else
{
// don't print ticket!
bPrintTicket = 0;
// print out that plane is full
printf("Plane is full, next flight in 3 hours\n");
}
}
else
{
// economy is not full
printf("Your seat assignment is %d\n", nSeatAssignmentEconomy );
plane[(nSeatAssignmentEconomy - 1)] = 1;
nCurrentSeatAssignment = nSeatAssignmentEconomy;
nSeatAssignmentEconomy++;
nNumSeatsInEconomy++;
i++;
}
} // if( choice == 2 )


/****************************************************************/
/*************** FIRST CLASS SECTION ***************/
/****************************************************************/
if( 1 == choice )
{
// check for fisrt class full
if( nNumSeatsInFirst >= MAX_NUM_SEATS_IN_FIRST_CLASS )
{
// first class full
// check for economy class (plane) full
if( nNumSeatsInEconomy <= MAX_NUM_SEATS_IN_ECONOMY )
{
printf("The First Class section is full.\n");
printf("Would you like to sit in the economy ");
printf("section (Y or N)?");
scanf("%s", response);


if(toupper(response[0])=='Y')
{
printf("Your seat assignment is %d\n",nSeatAssignmentEconomy);
plane[nSeatAssignmentEconomy - 1] = 1;
nCurrentSeatAssignment = nSeatAssignmentEconomy;
nSeatAssignmentEconomy++;
nNumSeatsInEconomy++;
i++;
nClass = 2;
}
else
{
// don't print ticket!
bPrintTicket = 0;
printf("Next flight leaves in 3 hours.\n");
}
}
else
{
// don't print ticket!
bPrintTicket = 0;
// print out that plane is full
printf("Plane is full, next flight in 3 hours\n");
}
}
else
{
// first is not full
printf("Your seat assignment is %d\n", nSeatAssignmentFirstClass );
plane[(nSeatAssignmentFirstClass - 1)] = 1;
nCurrentSeatAssignment = nSeatAssignmentFirstClass;
nSeatAssignmentFirstClass++;
nNumSeatsInFirst++;

i++;
}
}

if( 1 == bPrintTicket )
{
printf(" ****************************************\n");
printf(" * *\n");
printf(" NAME:%s, %s \n",lastname,firstname);
printf(" * *\n");
printf(" CLASS:%d \n",nClass);
printf(" * *\n");
printf(" SEAT:%d \n",nCurrentSeatAssignment);
printf(" * *\n");
printf(" \n");
printf(" ****************************************\n");
}

}

printf("\nAll the seats for this flight are sold\n");

return 0;
}
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: java code for queue management systems, opengl code for fair queue, html code for airline reservation systems, mini projects for airline reservation using rmi, reservation program using queue in c, stack overflow seminar report, seminar topics data structure queue with source code,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Possibly Related Threads...
Thread Author Replies Views Last Post
  program code of solar tracking system using 8051 microcontroller 6 23,336 03-05-2018, 09:30 PM
Last Post: Guest
  matlab code for vehicle tracking using unscented kalman filter 3 16,876 26-03-2018, 08:57 PM
Last Post: fodayj
  matlab code for facial expression recognition using frequency domain 1 2,683 19-02-2018, 06:03 PM
Last Post: Guest
  matlab code shadow detection and removal in colour images using matlab 2 2,262 12-01-2018, 01:24 PM
Last Post: dhanabhagya
  java programmings for bus ticket reservation source code 1 6,221 09-11-2017, 11:28 PM
Last Post: Ayushi Nagar
  skin cancer detection using neural networks matlab code 13 3,895 23-10-2017, 02:52 PM
Last Post: Guest
  matlab code for digital watermarking using dct and dwt 5 4,423 19-05-2017, 02:59 PM
Last Post: jaseela123d
Smile source code for air ticket reservation system using html 2 1,381 26-04-2017, 07:43 PM
Last Post: Guest
  matlab code for a gender discrimination using neural networks 1 814 13-04-2017, 01:05 PM
Last Post: jaseela123d
  railway ticket reservation form coding in gui 1 1,298 13-04-2017, 09:45 AM
Last Post: jaseela123d

Forum Jump: