SlideShare a Scribd company logo
1 of 31
2017-2018
SUBJECT :- COMPUTER SCIENCE
TEACHER’S NAME:- VIVEK SINGH
Project - Railway Reservation
PRADEEP SAGAR
ROLL NO.
G.B.S.S.SCHOOL
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.
.: 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.
4.
.: CONTENTS :.
1. certificate
2. Acknowledgement
3. Source code
4. outputs
5.
//**********************************************
**************************
// PROJECT ON RAILWAY TICKET
RESERVATION
//**********************************************
**************************
//REQUIRED HEADER FILES
//**********************************************
**************************
#include<ctype.h>
#include<conio.h>
#include<fstream.h>
#include<string.h>
#include<process.h>
#include<stdio.h>
#include<dos.h>
//**********************************************
**************************
//STRUCTURE CONTAINING VARIABLES FOR RAILWAY
RESERVATION.
//**********************************************
**************************
struct railway
{
char
name[20],sex,from[20],rstatus[2],nat[10];
int passno,age,des;
};
//**********************************************
**************************
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.
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.
//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.
{
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.
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.
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.
//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)))
13.
t++;
trains.close();
do
{
if(t<5)
strcpy(r.rstatus,"C");
else strcpy(r.rstatus,"W");
if(t<8)
{
t++;
clrscr();
gotoxy(25,3);
cout<<"ADDITION OF NEW PASSENGER";
gotoxy(23,4);
cout<<"IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII"
;
gotoxy(20,6);
cout<<"TRAIN NAME :";
switch(c)
{
case '1':cout<<"SHATABADI";
break;
case '2':cout<<"KOLKATA -
MAIL";break;
case '3':cout<<"SUPERFAST
EXPRES"; break;
case '4':cout<<"RAWALPINDI EXPRES
";break;
case '5':cout<<"RAJDHANI
EXPRESS"; break;
}
getdata(t);
gotoxy(20,16);
cout<<"STATUS :";
14.
if(t<5)
cout<<"aCONFIRMED";
else cout<<"aWAITING LIST";
getch();
trains.open(filename,ios::out|ios::binary|io
s::app);
trains.write((char*)&r,sizeof(railway));
trains.close();
}
else
{
clrscr();
gotoxy(22,20);
cout<<"NO MORE TICKETS AVAILABLE FOR
THIS TRAINa";
getch();
}
gotoxy(12,25);
cout<<"aDO YOU WISH TO MAKE ANY MORE
RESERVATION ON THIS TRAIN(Y/N)";
do
{
choice1=getch() ;
choice1=toupper(choice1) ;
} while((choice1!='Y')&&(choice1!='N')) ;
} while(choice1=='Y') ;
gotoxy(12,25);
cout<<"DO YOU WISH TO MAKE ANY MORE
RESERVATION ON ANY TRAIN(Y/N)";
do
{
choice2=getch();
choice2=toupper(choice2);
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;
16.
trains.open(filename,ios::in|ios::binary|ios
::app);
while(trains.read((char
*)&r,sizeof(railway)))
{
k++;
}
trains.close();
if(p>k)
{
clrscr();
gotoxy(25,25);
cout<<"RECORD NOT FOUND.........a";
getch();
}
else
{
trains.open(filename,ios::in|ios::binary|ios::ap
p);
while(trains.read((char
*)&r,sizeof(railway)))
{
if(r.passno==p)
{
clrscr();
gotoxy(27,3);
cout<<"PASSENGER INFORMATION";
gotoxy(23,6);
cout<<"TRAIN NAME :";
switch(c)
{
case '1':cout<<"SHATABADI"; break;
case '2':cout<<"KOLKATA - MAIL";break;
17.
case '3':cout<<"SUPERFAST EXPRES";
break;
case '4':cout<<"RAWALPINDI EXPRES
";break;
case '5':cout<<"RAJDHANI EXPRESS";
break;
}
gotoxy(23,7);
cout<<"PASSENGER NO. :";
cout<<r.passno;
gotoxy(23,9);
cout<<"NAME OF PASSENGER :";
cout<<r.name;
gotoxy(23,10);
cout<<"SEX OF PASSENGER :";
cout<<r.sex;
gotoxy(23,11);
cout<<"AGE OF PASSENGER :";
cout<<r.age;
gotoxy(23,12);
cout<<"NATIONALITY :";
cout<<r.nat;
gotoxy(23,13);
cout<<"STARTING POINT :";
cout<<"DELHI";
gotoxy(23,14);
cout<<"DESTINATION :";
switch(r.des)
{
case 1:cout<<"JAMMUn"; break;
case 2:cout<<"KANYAKUMARIn"; break;
case 3:cout<<"BOMBAYn"; break;
case 4:cout<<"KOLKATAn";break;
}
gotoxy(23,16);
18.
cout<<"TICKET NO. :";
cout<<r.passno;
gotoxy(23,17);
cout<<"STATUS :";
if(strcmp(r.rstatus,"W")==0)
cout<<"WAITING LIST";
else cout<<"CONFIRMED";
gotoxy(5,25);
cout<<"PRESS ANY KEY TO CONTINUE....";
getch();
}
} trains.close();
}
}
//**********************************************
*****************************
//FUNCTION NAME : LIST
//DESCRIPTION : FUNCTION TO SHOW PASSENGER LIST
TRAIN WISE.
//**********************************************
*****************************
void train::list()
{
fstream trains;
char c,filename[8];
c=select();
switch(c)
{
case '1': strcpy(filename,"IND.DAT");
break;
case '2': strcpy(filename,"BRIT.DAT");
break;
19.
case '3': strcpy(filename,"GULF.DAT");
break;
case '4': strcpy(filename,"UNIT.DAT");
break;
case '5': strcpy(filename,"LUF.DAT");
break;
}
clrscr();
gotoxy(29,3);
cout<<"PASSENGER LIST";
gotoxy(27,4);
cout<<"IIIIIIIIIIIIIIIIIIIIIIIIIIIIII";
gotoxy(33,5);
switch(c)
{
case '1':cout<<"SHATABADI";
break;
case '2':cout<<"KOLKATA -
MAIL";break;
case '3':cout<<"SUPERFAST
EXPRES"; break;
case '4':cout<<"RAWALPINDI EXPRES
";break;
case '5':cout<<"RAJDHANI
EXPRESS"; break;
}
gotoxy(3,7);
cout<<"PASSENGER NUMBER";
gotoxy(27,7);
cout<<"PASSENGER-NAME";
gotoxy(62,7);
cout<<"RESERVATION STATUS";
int i=9;
trains.open (filename,ios::in|ios::binary);
20.
while(trains.read((char
*)&r,sizeof(railway)))
{
gotoxy(10,i);
cout<<r.passno;
gotoxy(30,i);
cout<<r.name;
gotoxy(66,i);
if (strcmp(r.rstatus,"C")==0)
cout<<"CONFIRMED";
else
cout<<"WAITING LIST";
i++;
}
gotoxy(25,25);
cout<<"aPRESS ANY KEY YO
CONTINUE........";
getch();
trains.close();
}
//**********************************************
*****************************
//FUNCTION NAME : MOD
//DESCRIPTION : FUMCTION TO GET MODIFY TICKET
// DETAILS ENTERED DURING RESERVATION
//**********************************************
*****************************
void train::mod()
{
ifstream fin;
ofstream fout;
railway t;
int p,flag;
21.
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();
int found=0;
gotoxy(10,3);
cout<<"ENTER PASSENGER NUMBER :";
cin>>p;
fin.open(filename);
fout.open("backup.dat",ios::binary);
clrscr();
gotoxy(25,3);
cout<<"MODIFICATION OF PASSENGER";
gotoxy(23,4);
cout<<"
IIIIIIIIIIIIIIIIIIIIIIIIIIIIInnnn ";
while(fin.read((char *)&t,sizeof(railway)))
{
if(t.passno==p)
{
found=1;
cout<<"Record foundnn";
cout<<"Enter New Name : ";gets(t.name);
22.
cout<<"Enter Sex : ";cin>>t.sex;
cout<<"Enter Nationality: ";gets(t.nat);
cout<<"Enter Age: ";cin>>t.age;
fout.write((char *)&t,sizeof(t));
}
else
{
fout.write((char*)&t,sizeof(t));
}
}
if(found==0){cout<<"nn!!Record not found";
getch(); return;}
fin.close();
fout.close();
remove(filename);
rename("backup.dat",filename);
getch();
clrscr();
gotoxy(20,25);
cout<<"aTICKET DETAILS SUCCESSFULLY
MODIFIED.....";
getch();
}
//**********************************************
**************************
//FUNCTION NAME : CANCEL
//DESCRIPTION : FUNCTION TO CANCEL A TICKET.
//**********************************************
**************************
void train::cancel()
{
fstream trains,trains1;
int p,k=0;
23.
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;
trains.open(filename,ios::in|ios::binary|ios::ap
p);
while(trains.read((char
*)&r,sizeof(railway)))
{
k++;
}
trains.close();
if(p>k)
{
clrscr();
gotoxy(25,24);
cout<<"aPASSENGER NUMBER DOES NOT
EXIST";
getch();
24.
return;
}
clrscr();
gotoxy(25,3);
cout<<"CANCELLATION OF TICKET";
trains.open(filename,ios::in|ios::binary);
trains1.open("TEMP.DAT",ios::out|ios::binary);
while (trains.read((char
*)&r,sizeof(railway)))
{
if(r.passno>p)
{
r.passno--;
trains1.write((char
*)&r,sizeof(railway));
}
else if (r.passno<p)
trains1.write((char
*)&r,sizeof(railway));
}
trains.close();
trains1.close();
remove(filename);
rename("TEMP.DAT",filename);
trains.open(filename,ios::in|ios::binary);
trains1.open("TEMP.DAT",ios::out|ios::binary);
while (trains.read((char
*)&r,sizeof(railway)))
{
if(r.passno<=5)
strcpy(r.rstatus,"C");
else
strcpy(r.rstatus,"W");
25.
trains1.write((char
*)&r,sizeof(railway));
}
trains.close();
trains1.close();
remove(filename);
rename("TEMP.DAT",filename);
clrscr();
gotoxy(25,24);
cout<<"a TICKET SUCCESSFULLY
CANCELLED........";
getch();
}
void train::srs()
{
clrscr();
cout<<"nnnt ---------R----------";
delay(125);
cout<<"nnnt -------- A---------";
delay(125);
cout<<"nnnt ---------I----------";
delay(25);
cout<<"nnnt ----------L----------
";
delay(125);
cout<<"nnnt ----------W--------
--";
delay(125);
cout<<"nnnt ----------A----------
";
delay(125);
26.
cout<<"nnnt ----------Y--------
--";
delay(425);
delay(425);
delay(425);
delay(425);
}
//**********************************************
**************************
// Main Function
//**********************************************
**************************
void main()
{
train obj;
obj.srs();
obj.srs1();
}
27.
OUTPUTS -
28.
29.
30.
31.

More Related Content

Similar to Railway reservation system project source code

Dispatching taxi / minibuses - about Kabina project
Dispatching taxi / minibuses - about Kabina projectDispatching taxi / minibuses - about Kabina project
Dispatching taxi / minibuses - about Kabina projectBogusz Jelinski
 
Final year project working documentation 2020
Final year project working documentation 2020Final year project working documentation 2020
Final year project working documentation 2020Vikram Singh
 
Final ams power_point_slides-------newwww
Final ams power_point_slides-------newwwwFinal ams power_point_slides-------newwww
Final ams power_point_slides-------newwwwvivekmsmech
 
cbse 12 computer science IP
cbse 12 computer science IPcbse 12 computer science IP
cbse 12 computer science IPD. j Vicky
 
Real time path planning based on hybrid-vanet-enhanced transportation system
Real time path planning based on hybrid-vanet-enhanced transportation systemReal time path planning based on hybrid-vanet-enhanced transportation system
Real time path planning based on hybrid-vanet-enhanced transportation systemShakas Technologies
 
C.S. project report on railway ticket reservation
C.S. project report on railway ticket reservationC.S. project report on railway ticket reservation
C.S. project report on railway ticket reservationVirat Prasad
 
Lucian Smith - Modular Modeling: Standards and Tools (IMAG)
Lucian Smith - Modular Modeling: Standards and Tools (IMAG)Lucian Smith - Modular Modeling: Standards and Tools (IMAG)
Lucian Smith - Modular Modeling: Standards and Tools (IMAG)Lucian Smith
 
KUMARPAWAN (2)-1-1.pdf
KUMARPAWAN (2)-1-1.pdfKUMARPAWAN (2)-1-1.pdf
KUMARPAWAN (2)-1-1.pdfRajKamal754430
 
6 weeks vocational traning report about dlw varanasi
6 weeks vocational traning report about dlw varanasi6 weeks vocational traning report about dlw varanasi
6 weeks vocational traning report about dlw varanasiABHISHEK PRIYADARSHI
 
CS Project on Railway Tickect Reservation for class 12
CS Project on Railway Tickect Reservation for class 12CS Project on Railway Tickect Reservation for class 12
CS Project on Railway Tickect Reservation for class 12anekant28
 
Robocraft design of prototype of aircraft
Robocraft   design of prototype of aircraftRobocraft   design of prototype of aircraft
Robocraft design of prototype of aircraftTank Chirag
 
Project report - Web Browser in Java by Devansh Koolwal
Project report - Web Browser in Java by Devansh KoolwalProject report - Web Browser in Java by Devansh Koolwal
Project report - Web Browser in Java by Devansh KoolwalDevansh Koolwal
 
Estimation of Base Drag On Supersonic Cruise Missile
Estimation of Base Drag On Supersonic Cruise MissileEstimation of Base Drag On Supersonic Cruise Missile
Estimation of Base Drag On Supersonic Cruise MissileIRJET Journal
 
Sachin Foujdar , BCA Third Year
Sachin Foujdar , BCA Third YearSachin Foujdar , BCA Third Year
Sachin Foujdar , BCA Third YearDezyneecole
 
Universal JavaScript - Frontend United Athens 2017
Universal JavaScript - Frontend United Athens 2017Universal JavaScript - Frontend United Athens 2017
Universal JavaScript - Frontend United Athens 2017Luciano Mammino
 
Web Vulnerability Scanner project Report
Web Vulnerability Scanner project ReportWeb Vulnerability Scanner project Report
Web Vulnerability Scanner project ReportVikas Kumar
 
cbse 12 computer science investigatory project
cbse 12 computer science investigatory project  cbse 12 computer science investigatory project
cbse 12 computer science investigatory project D. j Vicky
 

Similar to Railway reservation system project source code (20)

Dispatching taxi / minibuses - about Kabina project
Dispatching taxi / minibuses - about Kabina projectDispatching taxi / minibuses - about Kabina project
Dispatching taxi / minibuses - about Kabina project
 
Final year project working documentation 2020
Final year project working documentation 2020Final year project working documentation 2020
Final year project working documentation 2020
 
Final ams power_point_slides-------newwww
Final ams power_point_slides-------newwwwFinal ams power_point_slides-------newwww
Final ams power_point_slides-------newwww
 
cbse 12 computer science IP
cbse 12 computer science IPcbse 12 computer science IP
cbse 12 computer science IP
 
Real time path planning based on hybrid-vanet-enhanced transportation system
Real time path planning based on hybrid-vanet-enhanced transportation systemReal time path planning based on hybrid-vanet-enhanced transportation system
Real time path planning based on hybrid-vanet-enhanced transportation system
 
C.S. project report on railway ticket reservation
C.S. project report on railway ticket reservationC.S. project report on railway ticket reservation
C.S. project report on railway ticket reservation
 
Lucian Smith - Modular Modeling: Standards and Tools (IMAG)
Lucian Smith - Modular Modeling: Standards and Tools (IMAG)Lucian Smith - Modular Modeling: Standards and Tools (IMAG)
Lucian Smith - Modular Modeling: Standards and Tools (IMAG)
 
KUMARPAWAN (2)-1-1.pdf
KUMARPAWAN (2)-1-1.pdfKUMARPAWAN (2)-1-1.pdf
KUMARPAWAN (2)-1-1.pdf
 
Helling Portfolio
Helling Portfolio Helling Portfolio
Helling Portfolio
 
6 weeks vocational traning report about dlw varanasi
6 weeks vocational traning report about dlw varanasi6 weeks vocational traning report about dlw varanasi
6 weeks vocational traning report about dlw varanasi
 
CS Project on Railway Tickect Reservation for class 12
CS Project on Railway Tickect Reservation for class 12CS Project on Railway Tickect Reservation for class 12
CS Project on Railway Tickect Reservation for class 12
 
Robocraft design of prototype of aircraft
Robocraft   design of prototype of aircraftRobocraft   design of prototype of aircraft
Robocraft design of prototype of aircraft
 
Project report - Web Browser in Java by Devansh Koolwal
Project report - Web Browser in Java by Devansh KoolwalProject report - Web Browser in Java by Devansh Koolwal
Project report - Web Browser in Java by Devansh Koolwal
 
Estimation of Base Drag On Supersonic Cruise Missile
Estimation of Base Drag On Supersonic Cruise MissileEstimation of Base Drag On Supersonic Cruise Missile
Estimation of Base Drag On Supersonic Cruise Missile
 
Concordia College fake diploma
Concordia College fake diplomaConcordia College fake diploma
Concordia College fake diploma
 
Sachin Foujdar , BCA Third Year
Sachin Foujdar , BCA Third YearSachin Foujdar , BCA Third Year
Sachin Foujdar , BCA Third Year
 
Mrcb forklift training
Mrcb forklift trainingMrcb forklift training
Mrcb forklift training
 
Universal JavaScript - Frontend United Athens 2017
Universal JavaScript - Frontend United Athens 2017Universal JavaScript - Frontend United Athens 2017
Universal JavaScript - Frontend United Athens 2017
 
Web Vulnerability Scanner project Report
Web Vulnerability Scanner project ReportWeb Vulnerability Scanner project Report
Web Vulnerability Scanner project Report
 
cbse 12 computer science investigatory project
cbse 12 computer science investigatory project  cbse 12 computer science investigatory project
cbse 12 computer science investigatory project
 

Recently uploaded

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 

Recently uploaded (20)

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 

Railway reservation system project source code

  • 1. 2017-2018 SUBJECT :- COMPUTER SCIENCE TEACHER’S NAME:- VIVEK SINGH Project - Railway Reservation PRADEEP SAGAR ROLL NO. G.B.S.S.SCHOOL
  • 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.
  • 4. 4. .: CONTENTS :. 1. certificate 2. Acknowledgement 3. Source code 4. outputs
  • 5. 5. //********************************************** ************************** // PROJECT ON RAILWAY TICKET RESERVATION //********************************************** ************************** //REQUIRED HEADER FILES //********************************************** ************************** #include<ctype.h> #include<conio.h> #include<fstream.h> #include<string.h> #include<process.h> #include<stdio.h> #include<dos.h> //********************************************** ************************** //STRUCTURE CONTAINING VARIABLES FOR RAILWAY RESERVATION. //********************************************** ************************** struct railway { char name[20],sex,from[20],rstatus[2],nat[10]; int passno,age,des; }; //********************************************** **************************
  • 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)))
  • 13. 13. t++; trains.close(); do { if(t<5) strcpy(r.rstatus,"C"); else strcpy(r.rstatus,"W"); if(t<8) { t++; clrscr(); gotoxy(25,3); cout<<"ADDITION OF NEW PASSENGER"; gotoxy(23,4); cout<<"IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII" ; gotoxy(20,6); cout<<"TRAIN NAME :"; switch(c) { case '1':cout<<"SHATABADI"; break; case '2':cout<<"KOLKATA - MAIL";break; case '3':cout<<"SUPERFAST EXPRES"; break; case '4':cout<<"RAWALPINDI EXPRES ";break; case '5':cout<<"RAJDHANI EXPRESS"; break; } getdata(t); gotoxy(20,16); cout<<"STATUS :";
  • 14. 14. if(t<5) cout<<"aCONFIRMED"; else cout<<"aWAITING LIST"; getch(); trains.open(filename,ios::out|ios::binary|io s::app); trains.write((char*)&r,sizeof(railway)); trains.close(); } else { clrscr(); gotoxy(22,20); cout<<"NO MORE TICKETS AVAILABLE FOR THIS TRAINa"; getch(); } gotoxy(12,25); cout<<"aDO YOU WISH TO MAKE ANY MORE RESERVATION ON THIS TRAIN(Y/N)"; do { choice1=getch() ; choice1=toupper(choice1) ; } while((choice1!='Y')&&(choice1!='N')) ; } while(choice1=='Y') ; gotoxy(12,25); cout<<"DO YOU WISH TO MAKE ANY MORE RESERVATION ON ANY TRAIN(Y/N)"; do { choice2=getch(); choice2=toupper(choice2);
  • 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;
  • 17. 17. case '3':cout<<"SUPERFAST EXPRES"; break; case '4':cout<<"RAWALPINDI EXPRES ";break; case '5':cout<<"RAJDHANI EXPRESS"; break; } gotoxy(23,7); cout<<"PASSENGER NO. :"; cout<<r.passno; gotoxy(23,9); cout<<"NAME OF PASSENGER :"; cout<<r.name; gotoxy(23,10); cout<<"SEX OF PASSENGER :"; cout<<r.sex; gotoxy(23,11); cout<<"AGE OF PASSENGER :"; cout<<r.age; gotoxy(23,12); cout<<"NATIONALITY :"; cout<<r.nat; gotoxy(23,13); cout<<"STARTING POINT :"; cout<<"DELHI"; gotoxy(23,14); cout<<"DESTINATION :"; switch(r.des) { case 1:cout<<"JAMMUn"; break; case 2:cout<<"KANYAKUMARIn"; break; case 3:cout<<"BOMBAYn"; break; case 4:cout<<"KOLKATAn";break; } gotoxy(23,16);
  • 18. 18. cout<<"TICKET NO. :"; cout<<r.passno; gotoxy(23,17); cout<<"STATUS :"; if(strcmp(r.rstatus,"W")==0) cout<<"WAITING LIST"; else cout<<"CONFIRMED"; gotoxy(5,25); cout<<"PRESS ANY KEY TO CONTINUE...."; getch(); } } trains.close(); } } //********************************************** ***************************** //FUNCTION NAME : LIST //DESCRIPTION : FUNCTION TO SHOW PASSENGER LIST TRAIN WISE. //********************************************** ***************************** void train::list() { fstream trains; char c,filename[8]; c=select(); switch(c) { case '1': strcpy(filename,"IND.DAT"); break; case '2': strcpy(filename,"BRIT.DAT"); break;
  • 19. 19. case '3': strcpy(filename,"GULF.DAT"); break; case '4': strcpy(filename,"UNIT.DAT"); break; case '5': strcpy(filename,"LUF.DAT"); break; } clrscr(); gotoxy(29,3); cout<<"PASSENGER LIST"; gotoxy(27,4); cout<<"IIIIIIIIIIIIIIIIIIIIIIIIIIIIII"; gotoxy(33,5); switch(c) { case '1':cout<<"SHATABADI"; break; case '2':cout<<"KOLKATA - MAIL";break; case '3':cout<<"SUPERFAST EXPRES"; break; case '4':cout<<"RAWALPINDI EXPRES ";break; case '5':cout<<"RAJDHANI EXPRESS"; break; } gotoxy(3,7); cout<<"PASSENGER NUMBER"; gotoxy(27,7); cout<<"PASSENGER-NAME"; gotoxy(62,7); cout<<"RESERVATION STATUS"; int i=9; trains.open (filename,ios::in|ios::binary);
  • 20. 20. while(trains.read((char *)&r,sizeof(railway))) { gotoxy(10,i); cout<<r.passno; gotoxy(30,i); cout<<r.name; gotoxy(66,i); if (strcmp(r.rstatus,"C")==0) cout<<"CONFIRMED"; else cout<<"WAITING LIST"; i++; } gotoxy(25,25); cout<<"aPRESS ANY KEY YO CONTINUE........"; getch(); trains.close(); } //********************************************** ***************************** //FUNCTION NAME : MOD //DESCRIPTION : FUMCTION TO GET MODIFY TICKET // DETAILS ENTERED DURING RESERVATION //********************************************** ***************************** void train::mod() { ifstream fin; ofstream fout; railway t; int p,flag;
  • 21. 21. 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(); int found=0; gotoxy(10,3); cout<<"ENTER PASSENGER NUMBER :"; cin>>p; fin.open(filename); fout.open("backup.dat",ios::binary); clrscr(); gotoxy(25,3); cout<<"MODIFICATION OF PASSENGER"; gotoxy(23,4); cout<<" IIIIIIIIIIIIIIIIIIIIIIIIIIIIInnnn "; while(fin.read((char *)&t,sizeof(railway))) { if(t.passno==p) { found=1; cout<<"Record foundnn"; cout<<"Enter New Name : ";gets(t.name);
  • 22. 22. cout<<"Enter Sex : ";cin>>t.sex; cout<<"Enter Nationality: ";gets(t.nat); cout<<"Enter Age: ";cin>>t.age; fout.write((char *)&t,sizeof(t)); } else { fout.write((char*)&t,sizeof(t)); } } if(found==0){cout<<"nn!!Record not found"; getch(); return;} fin.close(); fout.close(); remove(filename); rename("backup.dat",filename); getch(); clrscr(); gotoxy(20,25); cout<<"aTICKET DETAILS SUCCESSFULLY MODIFIED....."; getch(); } //********************************************** ************************** //FUNCTION NAME : CANCEL //DESCRIPTION : FUNCTION TO CANCEL A TICKET. //********************************************** ************************** void train::cancel() { fstream trains,trains1; int p,k=0;
  • 23. 23. 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; trains.open(filename,ios::in|ios::binary|ios::ap p); while(trains.read((char *)&r,sizeof(railway))) { k++; } trains.close(); if(p>k) { clrscr(); gotoxy(25,24); cout<<"aPASSENGER NUMBER DOES NOT EXIST"; getch();
  • 24. 24. return; } clrscr(); gotoxy(25,3); cout<<"CANCELLATION OF TICKET"; trains.open(filename,ios::in|ios::binary); trains1.open("TEMP.DAT",ios::out|ios::binary); while (trains.read((char *)&r,sizeof(railway))) { if(r.passno>p) { r.passno--; trains1.write((char *)&r,sizeof(railway)); } else if (r.passno<p) trains1.write((char *)&r,sizeof(railway)); } trains.close(); trains1.close(); remove(filename); rename("TEMP.DAT",filename); trains.open(filename,ios::in|ios::binary); trains1.open("TEMP.DAT",ios::out|ios::binary); while (trains.read((char *)&r,sizeof(railway))) { if(r.passno<=5) strcpy(r.rstatus,"C"); else strcpy(r.rstatus,"W");
  • 25. 25. trains1.write((char *)&r,sizeof(railway)); } trains.close(); trains1.close(); remove(filename); rename("TEMP.DAT",filename); clrscr(); gotoxy(25,24); cout<<"a TICKET SUCCESSFULLY CANCELLED........"; getch(); } void train::srs() { clrscr(); cout<<"nnnt ---------R----------"; delay(125); cout<<"nnnt -------- A---------"; delay(125); cout<<"nnnt ---------I----------"; delay(25); cout<<"nnnt ----------L---------- "; delay(125); cout<<"nnnt ----------W-------- --"; delay(125); cout<<"nnnt ----------A---------- "; delay(125);
  • 26. 26. cout<<"nnnt ----------Y-------- --"; delay(425); delay(425); delay(425); delay(425); } //********************************************** ************************** // Main Function //********************************************** ************************** void main() { train obj; obj.srs(); obj.srs1(); }
  • 28. 28.
  • 29. 29.
  • 30. 30.
  • 31. 31.