RT Airlines Service

 #include<stdio.h>

#include<stdlib.h>

#include<conio.h>

#include<graphics.h>


struct kush

{

   char passport[6];

   char name[20];

   char destination[15];

   int seat_num;

   char email[20];

   struct kush *following;

}

*begin, *stream;

struct kush *dummy;


void main()

{


  void reserve(int x), cancel(), display(), savefile();

  int choice,p;

  int num=1;

  //begin=stream=NULL;


  do

  {

  textbackground(BLUE);

  window(1,1,80,60);

  clrscr();

  textbackground(BLACK);

  window(10,5,70,22);

  clrscr();

   textcolor(YELLOW);

   gotoxy(6,2);

   for(p=0;p<52;p++)

   {


   cprintf("%c",31);

}

  gotoxy(12,3);


  cprintf("WELCOME TO RT LAVKUSH'S AIRLINE SERVICE");

  gotoxy(6,4);

   for(p=0;p<52;p++)

   {


   cprintf("%c",30);

}


textcolor(WHITE);

gotoxy(10,5);

cprintf(" Please Enter Your Choice From Below (1-4)");

gotoxy(10,6);

cprintf("-------------------------------------------");

textcolor(13);

gotoxy(15,8);

cprintf("1.Reservation");

gotoxy(15,10);

cprintf("2.Cancel Reservation");

gotoxy(15,12);

cprintf("3.Display Reservation");

gotoxy(15,14);

cprintf("4.EXIT");

textcolor(YELLOW);

gotoxy(20,16);

cprintf("Enter Your Choice:");

scanf("%d",&choice);

  // fflush(stdin);

//system("cls");     //extra


switch(choice)

{

case 1:

  reserve(num);

  num++;

  break;

case 2:

  cancel();

  break;

case 3:

  display();

  break;

case 4:

{

   savefile();

   break;

}

default:

// textbackground(WHITE);

// window(1,1,80,60);               //extra

// clrscr();

textcolor(RED+BLINK);

gotoxy(25,18);

   cprintf("Sorry Try Again");

}

getch();

  }while(choice!=4);

  closegraph();

}

//*****************************************************************

void details()

{

textcolor(LIGHTCYAN);

gotoxy(10,2);

cprintf("WELCOME TO RT LAVKUSH'S AIRLINE SERVICE");

textcolor(BLACK);

gotoxy(4,5);

cprintf("Enter Your Passport Number:");

cgets(stream->passport);

//fflush(stdin);

gotoxy(4,7);

cprintf("Enter Your Name:");

cgets(stream->name);

// fflush(stdin);

gotoxy(4,9);

cprintf("Enter Your Email:");

cgets(stream->email);

//  fflush(stdin);

gotoxy(4,11);

cprintf("Enter The Destination:");

cgets(stream->destination);

// fflush(stdin);

}

//*******************************************************************

//void details();


void reserve(int x)

{

textbackground(YELLOW);

window(1,1,80,60);

clrscr();

   stream=begin;

   if(begin==NULL)

   {

   begin=stream=(struct kush*)malloc(sizeof(struct kush));

   details();

   stream->following=NULL;

   textcolor(BLACK+BLINK);

   gotoxy(15,15);

   cprintf(" Seat Booking Successfull! \n");

   gotoxy(15,16);

   cprintf(" Your Seat Number is : %d",x);

   stream->seat_num=x;

   return;

   }

   else if(x>1)

   {

textbackground(RED);

window(1,1,80,60);

clrscr();

textcolor(WHITE+BLINK);

gotoxy(12,12);

   cprintf("Oops! Seat Full : Please Try To Next Time");

   return;

   }

   else

   {

   while(stream->following)

   stream=stream->following;

   stream->following=(struct kush*)malloc(sizeof(struct kush));

   stream=stream->following;

   details();

   stream->following=NULL;

   printf("\n\tSeat booking successful!");

   printf("\n\tYour seat number is: Seat A-%d",x);

   stream->seat_num=x;

   return;

   }

}


//**********************************************************************

void savefile()

{

   FILE *fpointer=fopen("mufti records","w");

   if(!fpointer)

   {

  printf("\nCann't open file!");

  return;

  //Sleep(800);

   }

   stream=begin;

   while(stream)

   {

fprintf(fpointer, "%-6s", stream->passport);

fprintf(fpointer, "%-15s", stream->name);

fprintf(fpointer, "%-15s", stream->email);

fprintf(fpointer, "%-15s", stream->destination);

fprintf(fpointer, "\n");

stream=stream->following;

   }

   textbackground(16);

   clrscr();

   textcolor(YELLOW+BLINK);

   gotoxy(14,10);

  cprintf("Thanks For Visiting Please Visit Again");

   fclose(fpointer);

}

//*********************************************************************

void display()

{

   stream=begin;

   while(stream)

   {

   printf("\n\n Passport Number:%-6s",stream->passport);

   printf("\n   Name:%-15s",stream->name);

   printf("\n   Email:%-15s",stream->email);

   printf("\n   Seat Number:A-%d",stream->seat_num);

   printf("\n   Destination:%-15s",stream->destination);

   printf("\n\n++*=================================================*++");

   stream=stream->following;

   }

}

//************************************************************************

void cancel()

{

  char passport[6];

  stream=begin;

  system("cls");

      printf("\n\nEnter Passport Number To Delete Record?");

      gets(passport);  fflush(stdin);

      if(strcmp(begin->passport,passport)==0)

      {

dummy=begin;

begin=begin->following;

free(dummy);

printf("booking has been deleted");

//Sleep(800);

return;

  }

      while(stream->following)

      {

if(strcmp(stream->following->passport,passport)==0)

{

    dummy=stream->following;

    stream->following=stream->following->following;

    free(dummy);

printf("Reservation has been deleted");

    getch();

    //Sleep(800);

    return;

}

stream=stream->following;

      }

      printf("passport number is wrong please check your passport:");

}




Previous Post Next Post