Professional Documents
Culture Documents
PPPPPPPPPPPPPPPPPPPPPPPPPPPPP
PPPPPPPPPPPPPPPPPPPPPPPPPPPPP
h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#include<fstream.h>
{
public:
int nop;
int trno;
int ticketno;
double pnr;
int seatno[300];
int trainno;
char tname[30];
char date[20];
double trans;
char adult;
char name[80];
int child;
char sex[10];
int age[10];
char from[30];
char to[30];
int fare;
char *chp;
void input();
void output();
int city();
char clas[6];
char* coach(char*);
void show_details();
public:
int a;
char b[50];
char c[6];
char d[6];
int t;
char tn[50];
char arr[6];
char dep[6];
void display();
void e_enter();
}; //class 'train' ends here
void main()
clrscr();
clrscr();
for(int i=5;i<31;i++)
gotoxy(i,1);
cout<<"*";
for(int j=1;j<45;j++)
gotoxy(j,40);
cout<<"*";
for(int k=1;k<=94;k++)
gotoxy(5,k);
cout<<"*";
for(int l=1;l<=25;l++)
gotoxy(75,l);
cout<<"*";
int rent;
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Delhi")==0))
rent=345;
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Mumbai")==0))
{
rent=796;
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Pune")==0))
rent=650;
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Lucknow")==0))
rent=16;
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Chandigarh")==0))
rent=248;
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Surat")==0))
rent=710;
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Howrah")==0))
rent=550;
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Jodhpur")==0))
{
rent=623;
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Jammu Tawi")==0))
rent=567;
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Patna")==0))
rent=190;
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Gorakhpur")==0))
rent=165;
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Chennai")==0))
rent=2000;
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Etawah")==0))
rent=150;
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Ahmedabad")==0))
rent=600;
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Puri")==0))
rent=650;
return rent;
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Delhi")==0))
{strcpy(clas,"AC3");
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Mumbai")==0))
{strcpy(clas,"s2");
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Chandigarh")==0))
{strcpy(clas,"AC1");
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Howrah")==0))
{strcpy(clas,"s4");
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Patna")==0))
{strcpy(clas,"s5");
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Etawah")==0))
{strcpy(clas,"s6");
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Jodhpur")==0))
{strcpy(clas,"AC2");
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Jammu Tawi")==0))
{strcpy(clas,"s1");
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Surat")==0))
{strcpy(clas,"s8");
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Gorakhpur")==0))
{strcpy(clas,"s6");
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Pune")==0))
{strcpy(clas,"s3");
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Puri")==0))
{strcpy(clas,"s7");
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Ahemadabad")==0))
{strcpy(clas,"AC1");
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Lucknow")==0))
{strcpy(clas,"s4");
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Chennai")==0))
{strcpy(clas,"AC3");
return clas;
box();
gotoxy(31,1);
textcolor(14);
gotoxy(23,3);
textcolor(14);
cprintf("......................................");
gotoxy(23,4);
textcolor(11);
gotoxy(23,5);
textcolor(14);
cprintf("......................................");
gotoxy(12,10);
textcolor(3);
cprintf("Made by::");
gotoxy(13,11);
textcolor(4) ;
gotoxy(13,12);
textcolor(4);
gotoxy(13,13);
textcolor(4) ;
cprintf("KUSHAGRA GUPTA Class::XII Sec.::science");
gotoxy(19,16);
textcolor(14);
cprintf("--------------------------------------------");
gotoxy(19,17);
textcolor(14);
cprintf("|");
gotoxy(20,17);
textcolor(3);
gotoxy(34,18);
textcolor(3);
gotoxy(19,19);
textcolor(14);
cprintf("--------------------------------------------");
gotoxy(64,17);
textcolor(14);
cprintf("|");
gotoxy(20,24);
textcolor(6);
getch();
clrscr();
}
void welcomepg2() //function definition of welcomepage2
box();
gotoxy(23,5);
textcolor(6);
cprintf("INDIAN.......NATIONAL........RAILWAYS");
gotoxy(23,10);
textcolor(2);
gotoxy(37,12);
textcolor(4);
cprintf("*T*O*");
gotoxy(23,14);
textcolor(3);
cprintf("----@@-----------------------@@------");
gotoxy(23,15);
textcolor(4) ;
cprintf("------KANPUR--CENTRAL--STATION-------");
gotoxy(23,16);
textcolor(5);
cprintf("----@@-----------------------@@------");
gotoxy(23,24);
textcolor(6);
char l;
cin>>l;
if((l=='y')||(l=='Y'))
clrscr();
else
exit(1);
int z;
do
gotoxy(15,3);
textcolor(15);
cprintf("*************************************************");
gotoxy(15,4);
textcolor(2);
gotoxy(15,5);
textcolor(15);
cprintf("*************************************************");
gotoxy(15,8);
textcolor(6);
gotoxy(15,10);
textcolor(3);
gotoxy(15,12);
textcolor(4);
gotoxy(15,14);
textcolor(5);
gotoxy(15,16);
textcolor(15);
gotoxy(15,18);
textcolor(5);
gotoxy(15,20);
textcolor(15);
gotoxy(15,22);
textcolor(15);
gotoxy(25,24);
textcolor(9);
cin>>z;
case 1:input_reserve();
getch();
clrscr();
break;
case 2:out_reserve();
getch();
clrscr();
break;
case 3:res_enquiry();
getch();
clrscr();
break;
case 4:res_cancel();
getch();
clrscr();
break;
case 5:enquiry();
getch();
clrscr();
break;
case 6:add_train();
getch();
clrscr();
break;
case 7:del_train();
getch();
clrscr();
break;
case 8:exit(0);
break;
} //end of switch
while(z<8);
void input_reserve()
clrscr();
ofstream f("rinfo.dat",ios::binary);
box();
r1.input();
f.write((char*)&r1,sizeof(r1));
f.close();
void reservation::input()
randomize();
gotoxy(18,3);
cprintf("----------------------------------------");
gotoxy(18,4);
gotoxy(18,5);
cprintf("----------------------------------------");
gotoxy(8,7);
textcolor(9);
cout<<"Ticket No.::";
gotoxy(8,8);
textcolor(9);
cprintf("Date::");
gotoxy(8,9);
textcolor(9);
cprintf("Train no.::");
gotoxy(8,10);
textcolor(9);
cprintf("Train Name::");
gotoxy(17,13);
cprintf("---------------------------------------");
gotoxy(18,14);
textcolor(9);
cprintf("From station");
gotoxy(34,14);
textcolor(14);
cprintf("|");
gotoxy(35,14);
textcolor(9);
cprintf("to");
gotoxy(37,14);
textcolor(14);
cprintf("|");
gotoxy(45,14);
textcolor(9);
cprintf("Station");
gotoxy(17,16);
cprintf("---------------------------------------");
gotoxy(20,7);
cin>>ticketno;
gotoxy(14,8);
gets(date);
gotoxy(19,9);
cin>>trno;
gotoxy(21,10);
gets(tname);
gotoxy(19,15);
gets(from);
gotoxy(45,15);
gets(to);
gotoxy(8,17);
textcolor(9);
cprintf("Passenger Details->");
gotoxy(30,17);
textcolor(9);
cprintf("Adults::");
cin>>adult;
gotoxy(41,17);
textcolor(9);
cprintf("Child::");
cin>>child;
gotoxy(53,17);
textcolor(9);
cprintf("Total Passengers::");
cin>>nop;
gotoxy(7,18);
cprintf("-------------------------------------------------------------------");
int y=0;
for(int i=0;i<nop;i++,y++)
gotoxy(8,19);
cout<<"Name";
gotoxy(30,19);
cout<<"Age";
gotoxy(48,19);
cout<<"Sex(m\f)";
gotoxy(7,20+y);
cout<<i+1<<".";
gotoxy(9,20+y);
gets(name);
gotoxy(30,20+y);
cin>>age[i];
gotoxy(48,20+y);
cin>>sex[i];
seatno[i]=random(5-300+1)+300;
chp=coach(clas);
fare=nop*city();
trans=random(400-124524+1)+124524;
pnr=random(50-1245687+1)+1245687;
}
//***********function definition for displaying reservation ticket***********
void out_reserve()
ifstream f1("rinfo.dat",ios::binary);
int g;
clrscr();
box();
gotoxy(18,2);
cprintf("---------------------------------------");
textcolor(6);
gotoxy(18,4);
cprintf("---------------------------------------");
gotoxy(7,5);
textcolor(4);
cin>>g;
f1.read((char*)&r2,sizeof(r2));
if(r2.ticketno==g)
gotoxy(8,8);
textcolor(6);
cout<<"Date::"<<r2.date;
gotoxy(50,8);
textcolor(6);
cout<<"Class::";
cout<<r2.chp;
gotoxy(8,9);
textcolor(6);
cout<<"Train no.::"<<r2.trno;
gotoxy(8,10);
textcolor(6);
cout<<"Train Name::"<<r2.tname;
gotoxy(17,11);
cprintf("--------------------------------------------");
gotoxy(18,12);
textcolor(6);
cprintf("Boarding At");
gotoxy(19,13);
cout<<r2.from;
gotoxy(34,12);
textcolor(14);
cprintf("|");
gotoxy(35,12);
textcolor(9);
cprintf("to");
gotoxy(37,12);
textcolor(14);
cprintf("|");
gotoxy(45,12);
textcolor(9);
cprintf("Station");
gotoxy(45,13);
cout<<r2.to;
gotoxy(17,14);
cprintf("--------------------------------------------");
int o=0;
gotoxy(6,16);
cprintf("---------------------------------------------------------------------");
for(int j=0;j<r2.nop;j++,o++)
gotoxy(8,17);
cout<<"Name";
gotoxy(28,17);
cout<<"Age";
gotoxy(40,17);
cout<<"Sex(m\f)";
gotoxy(50,17);
cout<<"Seat no.";
gotoxy(7,18+o);
cout<<j+1<<".";
gotoxy(9,18+o);
puts(r2.name);
gotoxy(29,18+o);
cout<<r2.age[j];
gotoxy(41,18+o);
cout<<r2.sex[j];
gotoxy(51,18+o);
cout<<r2.seatno[j];
gotoxy(8,23);
textcolor(2);
cout<<"T.Cash::Rs.";
cout<<r2.fare;
gotoxy(50,7);
textcolor(2);
cout<<"Trans_ID::";
cout<<r2.trans;
gotoxy(8,7);
textcolor(2);
cout<<"PNR No.::";
cout<<r2.pnr;
char b;
gotoxy(23,25);
getch();
}
else
{ char a;
gotoxy(18,13);
gotoxy(18,24);
getch();
f1.close();
void train::display()
gotoxy(10,10);
cout<<"TRAIN NO.::"<<a;
gotoxy(10,12);
cout<<"TRAIN NAME::"<<b;
gotoxy(10,14);
cout<<"ARR::"<<c;
gotoxy(10,16);
cout<<"DEP::"<<d;
clrscr();
void enquiry()
train t2;
int n;
clrscr();
box();
ifstream f10("enquiry.dat",ios::binary);
gotoxy(18,3);
cprintf("---------------------------------------");
gotoxy(26,4);
cout<<"TRAIN ENQUIRY";
gotoxy(18,5);
cprintf("---------------------------------------");
gotoxy(10,6);
cin>>n;
while(!f10.eof())
f10.read((char*)&t2,sizeof(t2));
if(t2.t==n)
{
t2.display();
getch();
}}
f10.close();
void add_train()
int v,d=0;
train t7;
clrscr();
box();
gotoxy(15,10);
cin>>v;
ofstream f3("enquiry.dat",ios::app|ios::binary);
while(d<v)
t7.e_enter();
f3.write((char*)&t7,sizeof(t7));
d++;
d=0;
f3.close();
void train::e_enter()
clrscr();
box();
gotoxy(20,6);
cprintf("TRAIN ENQUIRY");
gotoxy(8,10);
cin>>a;
t=a;
gotoxy(8,14);
gets(b);
gotoxy(8,18);
gets(c);
gotoxy(8,22);
gets(d);
int g=0;
train t6;
ifstream f4("einfo.dat",ios::binary);
ofstream f5("einfo1.dat",ios::binary);
int t;
clrscr();
box();
cin>>t;
while(f4)
f4.read((char*)&t6,sizeof(t6));
if(t6.a!=t)
f5.write((char*)&t6,sizeof(t6));
g=0;
else
g=1;
remove("einfo.dat");
rename("einfo1.dat","einfo.dat");
if(g==0)
gotoxy(23,8);
gotoxy(23,20);
getch();
else
clrscr();
box();
gotoxy(20,15);
gotoxy(23,23);
getch();
f4.close();
f5.close();
}
//***********function definition to cancel reservation************
void res_cancel()
char w;
int g=0;
reservation r6;
ifstream f7("rinfo.dat",ios::binary);
ofstream f8("rinfo1.dat",ios::binary);
int tk;
clrscr();
box();
cin>>tk;
while(f7)
f7.read((char*)&r6,sizeof(r6));
if(r6.ticketno!=tk)
f8.write((char*)&r6,sizeof(r6));
g=0;
else
g=1;
}
remove("rinfo.dat");
rename("rinfo1.dat","rinfo.dat");
if(g==0)
gotoxy(23,10);
gotoxy(25,15);
getch();
else
clrscr();
box();
gotoxy(20,25);
gotoxy(19,38);
getch();
f7.close();
f8.close();
void res_enquiry()
clrscr();
box();
int d;
reservation r20;
ifstream f9("rinfo.dat",ios::binary);
gotoxy(18,3);
cprintf("---------------------------------------");
gotoxy(26,4);
cprintf("RESERVATION ENQUIRY");
gotoxy(18,5);
cprintf("---------------------------------------");
gotoxy(7,10);
cin>>d;
while(f9.read((char*)&r20,sizeof(r20)))
if(r20.ticketno==d)
{
gotoxy(18,13);
gotoxy(23,25);
getch();
clrscr();
box();
gotoxy(18,3);
cprintf("-----------------------------------------");
gotoxy(18,4);
gotoxy(18,5);
cprintf("-----------------------------------------");
gotoxy(8,8);
textcolor(6);
cout<<"Date::"<<r20.date;
gotoxy(50,8);
textcolor(6);
cout<<"Class::";
cout<<r20.chp;
gotoxy(8,9);
textcolor(6);
cout<<"Train no.::"<<r20.trno;
gotoxy(8,10);
textcolor(6);
cout<<"Train Name::"<<r20.tname;
gotoxy(17,11);
cprintf("--------------------------------------------");
gotoxy(18,12);
textcolor(6);
cprintf("Boarding At");
gotoxy(19,13);
cout<<r20.from;
gotoxy(34,12);
textcolor(14);
cprintf("|");
gotoxy(35,12);
textcolor(9);
cprintf("to");
gotoxy(37,12);
textcolor(14);
cprintf("|");
gotoxy(45,12);
textcolor(9);
cprintf("Station");
gotoxy(45,13);
cout<<r20.to;
gotoxy(17,14);
cprintf("--------------------------------------------");
int o=0;
gotoxy(6,16);
cprintf("---------------------------------------------------------------------");
for(int j=0;j<r20.nop;j++,o++)
gotoxy(8,17);
cout<<"Name";
gotoxy(28,17);
cout<<"Age";
gotoxy(40,17);
cout<<"Sex(m\f)";
gotoxy(50,17);
cout<<"Seat no.";
gotoxy(7,18+o);
cout<<j+1<<".";
gotoxy(9,18+o);
puts(r20.name);
gotoxy(29,18+o);
cout<<r20.age[j];
gotoxy(41,18+o);
cout<<r20.sex[j];
gotoxy(51,18+o);
cout<<r20.seatno[j];
gotoxy(8,23);
textcolor(2);
cout<<"T.Cash::Rs.";
cout<<r20.fare;
gotoxy(50,7);
textcolor(2);
cout<<"Trans_ID::";
cout<<r20.trans;
gotoxy(8,7);
textcolor(2);
cout<<"PNR No.::";
cout<<r20.pnr;
gotoxy(23,25);
getch();
else
gotoxy(18,13);
gotoxy(18,24);
getch();
clrscr();
box();
}
f9.close();
//*****************************END OF PROGRAM*******************************