2. 2.
.: CERTIFICATE :.
This is to certify that PRADEEP SAGAR student of GOVT.
BOYS SENIOR SECONDRAY SCHOOL has completed the
project titled “RAILWAY RESERVATION” during the
academic year 2017–2018 towards partial fulfillment of
credit for the Computer Science practical evaluation of
2018, under my supervision.
Signature:
MR. VIVEK SINGH
Department of Computer Science
GOVT. BOYS SENIOR SECONDARY SCHOOL
3. 3.
.: ACKNOWLEDGEMENT :.
“There are times when silence speaks so much more
loudly than words of praise to only as good as belittle a
person, whose words do not express, but only put a
veneer over true feelings, which are of gratitude at this
point of time.”
I would like to express my sincere gratitude to my
Computer Science mentor MR. VIVEK SINGH for his vital
support, guidance and encouragement – without which
this project would not have come forth. I would also like
to express my gratitude to the staff of the Department of
Computer Science at
GOVT. BOYS SENIOR SECONDARY SCHOOL
for their support during the making of this project.
6. 6.
//CLASS TO CONTROL ALL THE FUNCTIONS RELATE TO
RAILWAY RESERVATION.
//**********************************************
**************************
class train
{
private:
railway r;
void getdata(int);
void add();
void list();
void pinfo();
void cancel();
void mod();
char select();
public:
void srs1();
void srs();
};
//**********************************************
**************************
//FUNCTION NAME:SRS
//DESCRIPTION:THIS FUNCTION OPENS UP THE MAIN
MENU
// AND CALLS OTHER RELATED FUNCTIONS.
//**********************************************
**************************
void train::srs1()
{
do
{
clrscr();
7. 7.
char choice;
gotoxy(30,2);
cout<<"******MAIN MENU****** ";
cout<<endl;
gotoxy(30,7);
cout<<" 1-NEW RESERVATION ";
gotoxy(30,9);
cout<<" 2-PASSENGER INFO. ";
gotoxy(30,11);
cout<<" 3-MODIFY RECORD ";
gotoxy(30,13);
cout<<" 4-DISPLAY LIST ";
gotoxy(30,15);
cout<<" 5-CANCELLATION ";
gotoxy(30,17);
cout<<" 6-QUIT TO SYSTEM ";
gotoxy(34,22);
cout<<"ENTER CHOICE:";
choice=getch();
choice=toupper(choice);
switch(choice)
{
case '1':add(); break;
case '2':pinfo(); break;
case '3':mod(); break;
case '4':list(); break;
case '5':cancel();break;
case '6':exit(1);
default:cout<<"a";
}
}while(1);
}
//**********************************************
**************************
8. 8.
//FUNCTIONS NAME : SELECT
//DESCRIPTION : THIS FUNCTION OPENS UP A SUB
MENU FOR THE USER
// TO SELECT AN TRAIN FROM THE LIST.
//**********************************************
**************************
char train::select()
{
char choice;
do
{
clrscr();
gotoxy(25,5);
cout<<"SELECT A ";
gotoxy(23,6);
gotoxy(27,9);
cout<<"1-SHATABADIn";
gotoxy(27,10);
cout<<"2-KOLKATA - MAILn";
gotoxy(27,11);
cout<<"3-SUPERFAST EXPRESSn";
gotoxy(27,12);
cout<<"4-RAWALPINDI EXPRESSn";
gotoxy(27,13);
cout<<"5-RAJDHANI EXPRESSn";
gotoxy(27,15);
cout<<"R-RETURN TO MAIN MENUn";
gotoxy(27,16);
cout<<"Q-QUIT TO SYSTEMn";
gotoxy(30,20);
cout<<"ENTER CHOICE:";
choice=getch();
choice=toupper(choice);
switch(choice)
9. 9.
{
case '1':return(choice);
case '2':return(choice);
case '3':return(choice);
case '4':return (choice);
case '5':return(choice);
case 'R':srs1();
case 'Q':exit(1);
default:cout<<"a" ;select();
}
}while(1);
}
//**********************************************
**************************
//FUNCTION NAME:GETDATA
//DESCRIPTION:FUNCTION TO GET PASSENGER INFO.
FROM
// USER FOR ADDITION AND MODIFICATION.
//**********************************************
**************************
void train::getdata(int p)
{
char ch;
cout<<"n ROUTES ARE:";
cout<<"n 1.DELHI-JAMMU-DELHI";
cout<<"n 2.DELHI-KANYAKUMARI-DELHI";
cout<<"n 3.DELHI-BOMBAY-DELHI";
cout<<"n 4.DELHI-KOLKATA-DELHI";
cout<<"n PLEASE SELECT YOUR ROUTE:";
cin>>r.des;
clrscr();
r.passno=p;
10. 10.
gotoxy(20,7);
cout<<"PASSENGER NO.:";
cout<<r.passno;
gotoxy(20,9);
cout<<"ENTER NAME OF PASSENGER:";
gets(r.name);
gotoxy(20,10);
cout<<"ENTER SEX OF PASSENGER(M/F):";
cin>>r.sex;
while(1)
{
gotoxy(34,12);
cout<<" ";
if(r.sex=='m'||r.sex=='M'||r.sex=='f'||r.sex
=='F')
break;
gotoxy(34,12);
cout<<"ENTER M or F"<<endl;
getch();
gotoxy(34,12);
cout<<" ";
gotoxy(20,10);
cout<<" ";
gotoxy(20,10);
cout<<"ENTER SEX OF PASSENGER(M/F):";
cin>>r.sex;
}
gotoxy(20,11);
cout<<"ENTER AGE OF PASSENGER:";
cin>>r.age;
while(1)
{
gotoxy(34,12);
cout<<" ";
11. 11.
if(r.age>=4 && r.age<=100)
break;
gotoxy(34,12);
cout<<"ENTER CORRECT AGE";
getch();
gotoxy(34,12);
cout<<" ";
gotoxy(20,11);
cout<<" ";
gotoxy(20,11);
cout<<"ENTER AGE OF PASSENGER :";
cin>>r.age;
}
gotoxy(20,12);
cout<<"ENTER THE NATIONALITY :";
gets(r.nat);
gotoxy(20,13);
cout<<"STARTING POINT :";
cout<<"DELHIn";
gotoxy(20,14);
cout<<"DESTINATION POINT :";
switch(r.des)
{
case 1:cout<<"JAMMUn"; break;
case 2:cout<<"KANYAKUMARIn"; break;
case 3:cout<<"BOMBAYn"; break;
case 4:cout<<"KOLKATAn";break;
}
gotoxy(20,16);
cout<<"TICKET NO. :";
cout<<r.passno;
}
//**********************************************
**************************
12. 12.
//FUNCTION NAME : ADD
//DESCRIPTION : FUNCTION TO ADD THE DATA
PROVIDED
// FROM GETDATA INTO THE REQUIRED FILE.
//**********************************************
**************************
void train::add()
{
train temp;
int t;
fstream trains;
char c,filename[8],choice1,choice2;
do
{
t=0;
c=select();
switch(c)
{
case '1':strcpy(filename,"IND.DAT");
break;
case
'2':strcpy(filename,"BRIT.DAT");break;
case
'3':strcpy(filename,"GULF.DAT");break;
case
'4':strcpy(filename,"UNIT.DAT");break;
case '5':strcpy(filename,"LUF.DAT");
break;
}
trains.open(filename,ios::in|ios::binary|ios::ap
p);
while(trains.read((char*)&temp,sizeof(railway)))
15. 15.
} while((choice2!='Y')&&(choice2!='N'));
} while(choice2=='Y');
}
//**********************************************
*****************************
//FUNCTION NAME: PINFO
//DESCRIPTION: FUNCTION TO GET FULL DETAILS OF A
PARTICULAR PASSENGER
//**********************************************
*****************************
void train::pinfo()
{
fstream trains;
int p,k=0;
char c,filename[8];
c=select();
switch(c)
{
case '1':strcpy(filename,"IND.DAT");
break;
case
'2':strcpy(filename,"BRIT.DAT");break;
case
'3':strcpy(filename,"GULF.DAT");break;
case
'4':strcpy(filename,"UNIT.DAT");break;
case '5':strcpy(filename,"LUF.DAT");
break;
}
clrscr();
gotoxy(10,3);
cout<<"ENTER PASSENGER NUMBER :";
cin>>p;