#include
#include
#include
main()
{
FILE*fp,*ft;
char another,choice;
char name[20];
int tmp,x,fr,amt;
struct bnk
{
char name [20];
char add[20],dob[20],date[20];
int fcode,cl,fare;
int acno,c,fno,st,amt;
float ob,tk;
};
struct bnk e;
struct flt
{
char fname[20];
int fno,tk;
};
struct flt f;
long int recsize,recsize1;
fp=fopen("bnk.DAT","rb+");
if(fp==NULL)
{
fp=fopen("bnk.DAT","wb+");
exit();
}
recsize=sizeof(e);
recsize1=sizeof(f);
while(1)
{
int gd=DETECT,gm,maxx,maxy,x,y,button;
initgraph(&gd,&gm,"i:\tc\bin");
setbkcolor(1);
clrscr();
settextstyle(4,0,6);
outtextxy(200,1," Airline Reservation System ");
outtextxy(200,1," By IGCT Computers");
line(600,10,400,10);
printf("\n\n 1.New Customer");
printf("\n 2.List records");
printf("\n 3.New Flight ");
printf("\n 4.View Flight");
printf("\n 5.Delete records");
printf("\n 0.Exit");
printf("\n\n PLEASE ENTER YOUR CHOICE...\n ");
fflush (stdin);
choice=getche();
switch(choice)
{
case '1':
fseek(fp,0,SEEK_END);
another='y';
while(another=='y')
{
printf("\n Enter Customer Name...\n \t");
scanf("%s",&e.name);
printf("\n Enter Address...\n");
scanf("%s",&e.add);
printf("\n Enter DOB...\n");
scanf("%s",&e.dob);
printf("\nEnter Flight Code...\n");
scanf("%d",&e.fcode);
printf("\nEnter Date..\n");
scanf("%s",&e.date);
printf("\n Enter Class..\n");
scanf("%d",&e.cl);
printf("\nEnter Fare...\n");
scanf("%d",&fr);
printf("\n Enter Seats to Book..\n");
scanf("%d",&e.st);
if(e.cl==1)
{
e.fare=5000;
}
if(e.cl==2)
{
e.fare=3000;
}
else
{
e.fare=1000;
}
e.amt=e.fare+(e.st*fr)+(e.fare+.10);
printf("\n Total Payble amount with tax is %d",e.amt);
fwrite(&e,recsize,1,fp);
printf("\n Add Another Records(y/n)");
fflush(stdin);
another=getche();
}
break;
case '2':
printf("\nFCode\tName\tAddress\tDOB\tJ-Date\tClass\tSeats\tFare");
printf("\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
rewind(fp);
while(fread(&e,recsize,1,fp)==1)
printf("\n%d\t%s\t%s\t%s\t%s\t%d\t%d\t%d",e.fcode,e.name,e.add,e.dob,e.date,e.cl,e.st,e.amt);
getch();
break;
case '3':
fp=fopen("flt.DAT","rb+");
if(fp==NULL)
{
fp=fopen("flt.DAT","wb+");
exit();
}
fseek(fp,0,SEEK_END);
another='y';
while(another=='y')
{
printf("Enter Flight name,FLNO,Fare...\n");
scanf("%s %d %d",&f.fname,&f.fno,&f.tk);
fwrite(&f,recsize1,1,fp);
printf("\n Add Another Records(y/n)");
fflush(stdin);
another=getche();
}
break;
case '4':
printf("\nFlight Code \t FName \t Fare");
printf("\n=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*");
rewind(fp);
while(fread(&f,recsize1,1,fp)==1)
printf("\n %d \t %s \t %d",f.fno,f.fname,f.tk);
getch();
break;
case '5':
another ='y';
while(another=='y')
{
printf("\n enter name of Person to delete...\n");
scanf("%s",&name);
ft=fopen("pop.DAT","wb");
rewind(fp);
while(fread(&e,recsize,1,fp)==1)
{
if(strcmp(e.name,name)!=0)
fwrite(&e,recsize,1,ft);
}
fclose(fp);
fclose(ft);
remove("bnk.DAT");
rename("pop.DAT","bnk.DAT");
fp=fopen("bnk.DAT","rb+");
printf("delete another record(y/n)");
fflush(stdin);
another=getche();
}
break;
case '0':
fclose(fp);
exit();
}
}
}
Related Links :