SlideShare a Scribd company logo
KENDRIYA VIDYALAYA No.2
THIRUPPARANKUNDRAM
In Accordance With CBSE AISSCE 2014-
2015RAILWAY RESERVATION
Done by
Name: r.sridhar
Roll no: 4611810
KENDRIYA VIDYALAYA No.2
THIRUPPARANKUNDRAM
BONAFIDE CERTIFICATE
This is to certify that this project entitled as “RAILWAY
RESERVATION” is a record of Bonafide work carried out
by R.SRIDHAR and in the fulfilment of all requirements in
computer as prescribed by CBSE AISSCE 2014-2015 for
class XII in school KENDRIYA VIDYALAYA
THIRUPARANKUNDRAM, MADURAI-625005.
Date:
internal examiner
Principal :
external examiner
ACKNOWLEDGEMENT
At the outset, I would like to express my humble thanks to the god almighty, for
the kind grace showed on us to complete the project successfully.
I would also like to express my sincere thanks to our Principal, Smt.GEETHA
KUMARI for rendering necessary facilities to our project.
I also convey our immense gratititude to our academic project guide Smt.
K.SHANMUGA PRIYA for her wonderful suggestions, Constant support, ideas
and extraordinary guidance throughout the project.
I would also like to convey our heartfelt thanks to all the staff members of my
school, my friends and my parents for extending their support and encouraged
me a lot to complete my project work on time.
Contents
1. C++ INTRODUCTION.. . . . . . . . . . . . .
2. SYSTEM ENVIRONMENT.. . . . . . . . . . .
3. SYNOPSIS. . . . . . . . . . . . .
4. CODING . . . . . . . . . .. . . . . . . . . . . . . . . . .
5. OUTPUT SCREENS. . . . . . . . . . . . . . . . . . .
6. CONCLUSION. . . . . . . . . . . . . . . . . . . . . .
7. BIBLIOGRAPHY. . . . . . . . . . . . . . . . . . . . .
C++ INTRODUCTION:
C++ IS A STATICALLY TYPED, FREE-FORM, MULTI-PARADIGM,
COMPILED, GENERAL PURPOSE PROGRAMMING LANGUAGE. IT IS
REGARED AS AN INTERMEDIATE-LEVEL LANGUAGE, AS IT
COMPRISES A COMBINATION OF BOTH HIGH LEVEL AND LOW
LEVEL LANGUAGE FEATURES. DEVELOPED BY BJARNE
STROUSTRUPSTARTING IN 1979 AT BELL LABS, IT ADDS OBJECT
ORIENTED FEATURES, SUCH AS CLASSES, AND OTHER
ENHANCEMENTS TO THE C PROGRAMMING LANGUAGE.
ORIGINALLY NAMED C WITH CLASSES, THE LANGUAGE WAS
RENAMED C++ IN 1983, AS A PUN INVOLVING THE INCREMENT
OPERATOR.
C++ IS ONE OF THE MOST POPULAR PROGRAMMING LANGUAGES
AND IS IMPLEMENTED ON A WIDE VARIETY OF HARDWARE AND
OPERATING SYSTEM PLATFORMS.AS AN EFFICIENT COMPILER TO
NATIVE CODE,ITS APPLICATION DOMAINS INCLUDE SYSTEMS
SOFTWARE, APPLICATION SOFTWARE,DEVICE DRIVERS,EMBEDDED
SOFTWARE,HIGH PERFORMANCE SERVER AND CLIENT
APPLICATIONS,AND ENTERTAINMENT SOFTWARE. SEVERAL
GROUPS PROVIDE BOTH FREE AND PROPRIETARY C++ COMPILER
SOFTWARE, INCLUDING THE GUN PROJECT, MICROSOFT, INTEL AND
EMBARCADERO TECHNOLOGIES.C++ HAS GREATLY INFLUENCED
MANY OTHER POPULAR PROGRAMMING LANGUAGES, MOST
NOTABLY C++AND JAVA.
C++ IS ALSO USED FOR HARDWARE DESIGN, WHERE THE DESIGN IS
INITIALLY DESCRBED IN C++, THEN ANALYZED,
ARCHITECTURALLY CONSTRAINED AND SCHEDULED TO CREATE A
REGISTER TRANSFER LEVEL HARDWARE DESCRIPTION LANGUAGE
VIA HIGH LEVEL SYNTHESIS.
OBJECTS:
C++ INTRODUCES OBJECT ORIENTED PROGRAMMIMG (00P)
FEATURES TO C. IT OFFERS CLASSES, WHICH PROVIDE THE FOUR
FERTURES COMMONLY PRESENT IN OOP LANGUAGES:
ABSTRACTION, ENCAPSULATION, INHERITANCE, AND
POLMORPHISM. ONE DISTINGUISHING FEATURE OF C++ CLASSES
COMPARED TO CLASSES IN OTHER PROGRAMMING LANGUAGES IS
SUPPORT FOR DETEMINISTIC DESTRUCTORS, WHICH IN TURN
PROVIDE SUPPORT FOR THE RESOURCE ACQUISITION IS
INITIALIZATION CONCEPT.
SYSTEM ENVIRONMENT:
3.1. HARDWARE CONFIGURATION:
PROCESSOR : INTEL i3@512GHz
MONITORS : 800*600 MINIUM RESOLUTIONS AT
256 COLORS MINIMUM
RAM : 2GB
HARD DISK : 250GB
KEYBOARD : TVS 140
MOUSE : LOGITECH
3.2. SOFTWARE CONFIGURATION:
LANGUAGE : C++ PROGRAMMING LANGUAGE
OPERATING SYSTEM : WINDOWS ‘XP’.
SYNOPSIS
RAILWAY RESERVATION IS BASIC AND SAMPLE OF
RESERVING TICKETS AND CANCELLATION OF RESERVED
TICKETS
DESCRIPTION:
THIS C++ PROGRAM ON RAILWAY RESERVATION IS A
SIMPLE TEXT BASE PROGRAM. WE HAVE USED PROCEDURE
ORIENTED METHOD TO DESIGN THIS PROGRAM. THIS
PROGRAM IS WITH GRAPHICS TO KEEP PROGRAM FOR
BEGINNERS. PASSENGERS HAS BEEN ASKED FOR ID AND
PASSWORD FOR PROTECTION .WE HAVE GIVEN USER
FRIENDLY MENUS TO ENQUIRE, RESERVE, CANCEL THE
RAILWAY TICKETS.
IN THIS PROJECT, WE HAVE USED PROGRAMMING CONCEPT
LIKE IF LOOP, USER DEFINED FUNCTION, LIBRARY
FUNCTION.
SOURCE CODE
//administrator password is ‘abc’
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
#include<stdio.h>
#include<time.h>
#include<iomanip.h>
#include<fstream.h>
//Global variables
char f[2]="f"; //"f" for first-class
char s[2]="s"; //"s" for second-class
int addr,ad,flag=1,f1,d,m,i,amt; //amt -> amount
float tamt; //tamt -> total_amount
//First class : "login"
class login
{ public:
char id[20];
char pass[10]; //pass -> password
char *password;
void getid()
{ cout<<"Enter ID : "; gets(id);
password=getpass("Enter password : ");
strcpy(pass,password);
}
void displayid()
{
cout<<"User ID Information"<<endl<<endl;
cout<<"ID : ";puts(id);cout<<endl;
cout<<"Password : ";puts(pass);
}
};
//Second class : "detail" of train
class detail
{
public:
int tno; //tno -> Train Number
char tname[30]; //tname -> Train Name
char bp[20]; //bp -> Boarding Point
char dest[20]; //dest -> Destination
int c1,c1fare; //c1 -> First class c1fare -> First class fare
int c2,c2fare; //c2 -> Second class c2fare -> Second class fare
int d,m,y; //d -> date , m -> month , y -> year
void getdetail()
{
clrscr();
cout<<"Enter the details as follows"<<endl<<endl;
cout<<"Train number : ";cin>>tno;
cout<<"Train name : ";gets(tname);
cout<<"Boarding point : ";gets(bp);
cout<<"Destination point : ";gets(dest);
cout<<"No of seats in first class "<<endl;
cout<<"and fare per ticket : ";
cin>>c1>>c1fare;
cout<<"No of seats in second class "<<endl;
cout<<"and fare per ticket : ";
cin>>c2>>c2fare;
cout<<"Date of travel(in dd/mm/yy) : ";cin>>d>>m>>y;
}
void displaydetail()
{
cout<<"---------------------------------";
cout<<"-----------------------------------------------";
cout<<"Tr_No | Tr_Name | Start | Destin. |";
cout<<" FC_se | SC_se | Fr_FC | Fr_SC | Date of Jo.";
cout<<"n----------------------------------";
cout<<"----------------------------------------------n";
cout<<tno<<" "<<tname<<" "<<bp<<" "<<dest<<" "<<c1<<" "<<c2;
cout<<" "<<c1fare<<" "<<c2fare<<"
"<<d<<"/"<<m<<"/"<<y<<endl<<endl;
cout<<"----------------------------------";
cout<<"----------------------------------------------";
}
};
//Third class : "reser" for reservation
class reser : public detail
{
public:
int pnr; //pnr -> Passenger Name Record
int tno; //tno -> Train Number
char tname[30]; //tname -> Train Name
char bp[20];
char dest[20];
char pname[10][100];//pname -> Passenger Name
int age[20]; //age -> Age of passenger
char clas[10];
int nosr; //nosr -> No. of seats reserved
int i; //i -> Counter variable
int d,m,y;
int con; //con -> Concession amount
float amc; //amc -> Amount pay to customer
void getresdet();
void displayresdet();
};
void reser::getresdet() //getresdet -> get reservation details
{
clrscr();
cout<<"Enter the details as follows"<<endl<<endl;
cout<<"Train number : ";cin>>tno;
cout<<"Train name : ";gets(tname);
cout<<"Boarding point : ";gets(bp);
cout<<"Destination point : ";gets(dest);
cout<<"No of seats required : ";cin>>nosr;
for(i=0;i<nosr;i++)
{
cout<<"Passenger ("<<i+1<<") name : ";gets(pname[i]);
cout<<"Passenger ("<<i+1<<") age : ";cin>>age[i];
}
cout<<"Enter the class"<<endl;
cout<<"'f' for first class "<<endl;
cout<<"'s' for second class : ";gets(clas);
cout<<"Date of travel : ";cin>>d>>m>>y;
cout<<"nnEnter the concession category from belown";
cout<<"1.Militaryn2.Senior citizenn";
cout<<"3.Children(below 5 yrs)n4.Nonen";
cout<<"Enter your choice : ";cin>>con;
}
void reser::displayresdet() // Display reservation details
{
cout<<endl;
cout<<"-----------------------------------------------------n";
cout<<" RESERVATION STATUS n";
cout<<"-----------------------------------------------------n";
cout<<"PNR number : "<<pnr<<endl;
cout<<"Train number : "<<tno<<endl;
cout<<"Train name : ";puts(tname);
cout<<"Boarding point : ";puts(bp);
cout<<"Destination point : ";puts(dest);
cout<<"Number of seats reserved : "<<nosr<<endl;
for(i=0;i<nosr;i++)
{
cout<<"Passenger "<<i+1<<" name : ";puts(pname[i]);
cout<<"Passenger "<<i+1<<" age : "<<age[i]<<endl;
}
cout<<"Your class : ";puts(clas);
cout<<"Date of reservation : "<<d<<"/"<<m<<"/"<<y;
cout<<"nYour concession category : "<<con;
cout<<"nYou must pay : "<<amc<<endl;
cout<<"------------------------------------------------------n";
cout<<" END OF RESERVATION DETAILS OF PASSENGER n";
cout<<"------------------------------------------------------n";
}
//Fourth class : "canc" - cancellation of reserved ticket
class canc : public detail
{
public:
int pnr;
int tno;
char tname[100];
char bp[20];
char dest[20];
char pname[10][100];
int age[20];
int i;
char clas[10];
int nosc;
int d,m,y;
float amr;
void getcancdet()
{
cout<<"nnEnter the details as followsn";
cout<<"nPNR number : ";cin>>pnr;
cout<<"nDate of cancellation : ";cin>>d>>m>>y;
}
void displaycancdet();
};
void canc::displaycancdet()
{
cout<<"---------------------------------------------n";
cout<<" DISPLAY OF CANCELLATION n";
cout<<"---------------------------------------------n";
cout<<"PNR number : "<<pnr<<endl;
cout<<"Train number : "<<tno<<endl;
cout<<"Train name : ";puts(tname);
cout<<"Boarding point : ";puts(bp);
cout<<"Destination point : ";puts(dest);
cout<<"Your class : ";puts(clas);
cout<<"No of seats has been cancelled : "<<nosc<<endl;
for(i=0;i<nosc;i++)
{
cout<<"Passenger name : ";puts(pname[i]);
cout<<"Passenger age : "<<age[i]<<endl;
}
cout<<"Date of cancellation : "<<d<<"/"<<m<<"/"<<y<<endl;
cout<<"You can collect : Rs."<<amr<<endl;
cout<<"---------------------------------------------n";
cout<<" END OF CANCELLATION n";
cout<<"---------------------------------------------n";
}
//User-Defined Function(UDF) declaration part
void manage();
void can();
void user();
void database();
void res();
void reserve();
void displaypassdetail();
void cancell();
void enquiry();
//main function starts
void main()
{
int ch;
do
{
clrscr();
cout<<"-----------------------------------------------------------n";
cout<<" WELCOME TO ONLINE RAILWAY RESERVATION SYSTEM
n";
cout<<"-----------------------------------------------------------n";
cout<<"nn-----------------------------------------------------------n";
cout<<" MAIN MENU n";
cout<<"-----------------------------------------------------------n";
cout<<"nn1. Admin mode nn2. User mode nn3. Exitn";
cout<<"nEnter your choice : ";
cin>>ch;
cout<<endl;
switch(ch)
{
case 1:
database();
break;
case 2:
user();
break;
case 3:
exit(0);
}
}while(ch<=3);
getch();
}
//User-Defined Function(UDF) definition
void database() //Database function for administrator
{
char *password;
char *pass="abc";
password=getpass("nEnter the admininistrator password : ");
detail a;
fstream f;
int ch;
char c;
if(strcmp(pass,password)!=0)
{
cout<<"nEnter the password correctlyn";
cout<<"You are not permitted to login this moden";
getch();
goto h;
}
if(strcmp(pass,password)==0)
{
char c;
do
{
clrscr();
cout<<"n-----------------------------------------------------n";
cout<<" ADMINISTRATOR MENU n";
cout<<"-----------------------------------------------------n";
cout<<"nn1. Add detailsn";
cout<<"n2. Display detailsnn3. User managementn";
cout<<"n4. Display passenger detailsnn5. Return to main menun";
cout<<"nEnter your choice : ";
cin>>ch;
cout<<endl;
switch(ch)
{
case 1:
f.open("t.txt",ios::in|ios::out|ios::binary|ios::app);
do
{
a.getdetail();
f.write((char *) & a,sizeof(a));
cout<<"nnDo you want to add one more record?n";
cout<<"y-for Yesnn-for Non";
cout<<"Your answer : ";
cin>>c;
}while(c=='y');
f.close();
break;
case 2:
f.open("t.txt",ios::in|ios::out|ios::binary|ios::app);
f.seekg(0);
while(f.read((char *) & a,sizeof(a)))
{
a.displaydetail();
}
getch();
f.close();
break;
case 3:
manage();
break;
case 4:
displaypassdetail();
break;
}
}while(ch<=4);
f.close();
}
h:
}
void reserve()
{
int ch;
do
{
clrscr();
cout<<"1. Reservenn2. Return to the main menun";
cout<<"nEnter your choice : ";
cin>>ch;
cout<<endl;
switch(ch)
{
case 1:
res();
break;
}
}while(ch==1);
getch();
}
void res()
{
detail a;
reser b;
fstream f1,f2;
time_t t;
f1.open("t.txt",ios::in|ios::out|ios::binary);
f2.open("p.txt",ios::in|ios::out|ios::binary|ios::app);
int ch;
b.getresdet();
while(f1.read((char *) &a,sizeof(a)))
{
if(a.tno==b.tno)
{
if(strcmp(b.clas,f)==0)
{
if(a.c1>=b.nosr)
{
amt=a.c1fare;
addr=f1.tellg();
ad=sizeof(a.c1);
f1.seekp(addr-(7*ad));
a.c1=a.c1-b.nosr;
f1.write((char *) & a.c1,sizeof(a.c1));
if(b.con==1)
{
cout<<"nConcession category : MILITARY PERSONNELn";
b.amc=b.nosr*((amt*50)/100);
}
else if(b.con==2)
{
cout<<"nConcession category : SENIOR CITIZENn";
b.amc=b.nosr*((amt*60)/100);
}
else if(b.con==3)
{
cout<<"nConcession category : CHILDERN BELOW FIVEn";
b.amc=0.0;
}
else if(b.con==4)
{
cout<<"nYou cannot get any concessionn";
b.amc=b.nosr*amt;
}
srand((unsigned) time(&t));
b.pnr=rand();
f2.write((char *) & b,sizeof(b));
b.displayresdet();
cout<<"------------------------------------------------------n";
cout<<" YOUR TICKET HAS BEEN RESERVED n";
cout<<"------------------------------------------------------n";
}
else
{
cout<<"-----------------------------------------------------n";
cout<<" SORRY REQUESTED SEATS ARE NOT AVAILABLE n";
cout<<"-----------------------------------------------------n";
}
}
else if(strcmp(b.clas,s)==0)
{
if(a.c2>=b.nosr)
{
amt=a.c2fare;
addr=f1.tellg();
ad=sizeof(a.c2);
f1.seekp(addr-(5*ad));
a.c2=a.c2-b.nosr;
f1.write((char *) & a.c2,sizeof(a.c2));
if(b.con==1)
{
cout<<"nConcession category : MILITARY PRESONNELn";
b.amc=b.nosr*((amt*50)/100);
}
else if(b.con==2)
{
cout<<"nConcession category : SENIOR CITIZENn";
b.amc=b.nosr*((amt*60)/100);
}
else if(b.con==3)
{
cout<<"nConcession category : CHILDERN BELOW FIVEn";
b.amc=0.0;
}
else if(b.con==4)
{
cout<<"nYou can not get any concessionn";
b.amc=b.nosr*amt;
}
f2.write((char *) & b,sizeof(b));
b.displayresdet();
cout<<"-----------------------------------------------------n";
cout<<" YOUR TICKET HAS BEEN RESERVED n";
cout<<"-----------------------------------------------------n";
}
else
{
cout<<"--------------------------------------------------------n";
cout<<" SORRY REQIRED SEATS ARE NOT AVAILABLE n";
cout<<"--------------------------------------------------------n";
}
}
getch();
goto h;
}
else
{
flag=0;
}
}
if(flag==0)
{
cout<<"n-------------------------------------------------------n";
cout<<" WRONG TRAIN NUMBER n";
cout<<"-------------------------------------------------------n";
cout<<" ENTER THE TRAIN NO. FROM DATABASE n";
cout<<"-------------------------------------------------------n";
}
f1.close();
f2.close();
getch();
h:
}
void displaypassdetail()
{
fstream f;
reser b;
f.open("p.txt",ios::in|ios::out|ios::binary);
f.seekg(0);
while(f.read((char *) & b,sizeof(b)))
{
b.displayresdet();
}
f.close();
getch();
}
void enquiry()
{
fstream f;
f.open("t.txt",ios::in|ios::out|ios::binary);
detail a;
while(f.read((char *) & a,sizeof(a)))
{
a.displaydetail();
}
getch();
}
void cancell()
{
detail a;
reser b;
canc c;
fstream f1,f2,f3;
f1.open("t.txt",ios::in|ios::out|ios::binary);
f2.open("p.txt",ios::in|ios::out|ios::binary);
f3.open("cn.txt",ios::in|ios::out|ios::binary);
clrscr();
cout<<"n-----------------------------------------------------n";
cout<<" CANCELLATION MENU n";
cout<<"-----------------------------------------------------n";
c.getcancdet();
while(f2.read((char *) & b,sizeof(b)))
{
if(b.pnr==c.pnr)
{
c.tno=b.tno;
strcpy(c.tname,b.tname);
strcpy(c.bp,b.bp);
strcpy(c.dest,b.dest);
c.nosc=b.nosr;
for(int j=0;j<c.nosc;j++)
{
strcpy(c.pname[j],b.pname[j]);
c.age[j]=b.age[j];
}
strcpy(c.clas,b.clas);
if(strcmp(c.clas,f)==0)
{
while(f1.read((char *) & a,sizeof(a)))
{
if(a.tno==c.tno)
{
a.c1=a.c1+c.nosc;
d=a.d;
m=a.m;
addr=f1.tellg();
ad=sizeof(a.c1);
f1.seekp(addr-(7*ad));
f1.write((char *) & a.c1,sizeof(a.c1));
tamt=b.amc;
if((c.d==d)&&(c.m==m))
{
cout<<"You are cancelling at the date of departure."<<endl;
c.amr=tamt-((tamt*60)/100);
}
else if((c.m==m) && (c.d<d))
{
cout<<"You are cancelling at the month of departure."<<endl;
c.amr=tamt-((tamt*50)/100);
}
else if(m>c.m)
{
cout<<"You are cancelling "<<m-c.m<<" month before the date of
departure."<<endl;
c.amr=tamt-((tamt*20)/100);
}
else
{
cout<<"You are cancelling after the departure."<<endl;
cout<<"Your request cannot be completed."<<endl;
}
fstream fp2;
fp2.open("Temp.dat",ios::out);
f2.seekg(0,ios::beg);
while(f2.read((char*)&b,sizeof(b)))
{
if(b.pnr!=c.pnr)
{
fp2.write((char*)&b,sizeof(b));
}
}
fp2.close();
remove("p.txt");
rename("Temp.dat","p.txt");
c.displaycancdet();
goto h;
}
}
}
else if(strcmp(c.clas,s)==0)
{
while(f1.read((char *) & a,sizeof(a)))
{
if(a.tno==c.tno)
{
a.c2=a.c2+c.nosc;
d=a.d;
m=a.m;
addr=f1.tellg();
ad=sizeof(a.c2);
f1.seekp(addr-(5*ad));
f1.write((char *) & a.c2,sizeof(a.c2));
tamt=b.amc;
if((c.d==d)&&(c.m==m))
{
cout<<"You are cancelling at the date of departure."<<endl;
c.amr=tamt-((tamt*60)/100);
}
else if((c.m==m) && (c.d<d))
{
cout<<"You are cancelling at the month of departure."<<endl;
c.amr=tamt-((tamt*50)/100);
}
else if(m>c.m)
{
cout<<"You are cancelling "<<m-c.m<<" month before the date of
departure."<<endl;
c.amr=tamt-((tamt*20)/100);
}
else
{
cout<<"You are cancelling after the departure."<<endl;
cout<<"Your request cannot be completed."<<endl;
}
fstream fp2;
fp2.open("Temp.dat",ios::out);
f2.seekg(0,ios::beg);
while(f2.read((char*)&b,sizeof(b)))
{
if(b.pnr!=c.pnr)
{
fp2.write((char*)&b,sizeof(b));
}
}
fp2.close();
remove("p.txt");
rename("Temp.dat","p.txt");
c.displaycancdet();
goto h;
}
}
}
}
else
{
flag=0;
}
}
h:
if(flag==0)
{
cout<<"nEnter the correct PNR number.n";
}
f1.close();
f2.close();
f3.close();
getch();
}
void can()
{
int ch;
do
{
clrscr();
cout<<"n----------------------------------------------------n";
cout<<" CANCELLATION MENU n";
cout<<"----------------------------------------------------n";
cout<<"nn1. Cancelnn2. Return to the main menun";
cout<<"nEnter your choice:";
cin>>ch;
cout<<endl;
switch(ch)
{
case 1:
cancell();
break;
}
}while(ch==1);
getch();
}
void user()
{
login a;
int ch;
clrscr();
cout<<"n-----------------------------------------------------n";
cout<<" USER MENU n";
cout<<"-----------------------------------------------------n";
char *password;
fstream f;
f.open("id.txt",ios::in|ios::out|ios::binary);
char id[100];
cout<<"nnEnter your ID : "; gets(id);
password=getpass("nEnter your password : ");
while(f.read((char *) & a,sizeof(a)))
{
if((strcmp(a.id,id)==0)&&(strcmp(a.pass,password)==0))
{
do
{
clrscr();
cout<<"nn1. Reserve a ticketnn2. Cancel a ticket";
cout<<"nn3. Enquirynn4. Return to the main menun";
cout<<"nEnter your choice : ";
cin>>ch;
cout<<endl;
switch(ch)
{
case 1:
reserve();
break;
case 2:
cancell();
break;
case 3:
enquiry();
break;
}
}while(ch<=3);
goto j;
}
else
{
d=1;
}
}
if(d==1)
{
cout<<"nEnter user ID and password correctlyn";
}
getch();
j:
}
void manage()
{int ch;
fstream f;
char c;
login a;
clrscr();
cout<<"---------------------------------------------------------n";
cout<<" WELCOME TO THE USER MANAGEMENT MENU n";
cout<<"---------------------------------------------------------n";
do
{
cout<<"nn1. Add ID details of user n";
cout<<"n2. Display details of IDnn3. Return to the main menun";
cout<<"nEnter your choice : ";
cin>>ch;
cout<<endl;
switch(ch)
{
case 1:
f.open("id.txt",ios::in|ios::out|ios::binary|ios::app);
do
{
a.getid();
f.write((char *) & a,sizeof(a));
cout<<"nnDo you want to add one more record>?n";
cout<<"y-Yesnn-Non";
cout<<"Your answer : ";
cin>>c;
}while(c=='y');
f.close();
break;
case 2:
f.open("id.txt",ios::in|ios::out|ios::binary);
f.seekg(0);
while(f.read((char *) & a,sizeof(a)))
{
a.displayid();
}
f.close();
break;
}
}while(ch<=2);
getch();
}
Screen shots
Main menu
User mode
User mode menu
Enquiry
Reservation
Reservation status
Cancellation
Cancellation status
CONCLUSION
THIS PROJECT MEETS THE REQUIREMENTS
SPECIFICATION. IT GIVES LOGICAL SOLUTION FOR
LONG TIME PROBLEM ON RESERVING TRAIN TICKETS
AND CANCELLATION OF TICKETS BOOKED.
AND FINALLY IT SUCCESSFULLY RUNS AND REPORTS
ARE GENERATED IN A NEAT MANNER. AS AIMED IT
REDUCES LOT OF PAPER REFERENCE AND USER
FRIENDLY.
THE PROGRAMMING TECHNIQUE USED IN THE DESIGN
OF THE SYSTEM PROVIDES A SCOPE FOR FURTHER
EXPANSION AND IMPLEMENTATION OF ANY
CHANGES, WHICH MAY OCCUR IN FUTURE.
BIBLIOGRAPHY
1. http://en.wikipedia.org
2. Computer Science with c++ by Sumita Arora
3. Object oriented programming by Robert Lafore
4. www.cppforschool.com
5. www.bOtskOOl.com

More Related Content

Similar to Cs investrigatory project

Similar to Cs investrigatory project (20)

project report in C++ programming and SQL
project report in C++ programming and SQLproject report in C++ programming and SQL
project report in C++ programming and SQL
 
c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaon
 
Railway reservation(c++ project)
Railway reservation(c++ project)Railway reservation(c++ project)
Railway reservation(c++ project)
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual final
 
Railway reservation(c++ project)
Railway reservation(c++ project)Railway reservation(c++ project)
Railway reservation(c++ project)
 
Computer science project
Computer science projectComputer science project
Computer science project
 
Report Card making BY Mitul Patel
Report Card making BY Mitul PatelReport Card making BY Mitul Patel
Report Card making BY Mitul Patel
 
Oops presentation
Oops presentationOops presentation
Oops presentation
 
Sunil
SunilSunil
Sunil
 
Ticket window & automation system
Ticket window & automation systemTicket window & automation system
Ticket window & automation system
 
CS6311- PROGRAMMING & DATA STRUCTURE II LABORATORY
CS6311- PROGRAMMING & DATA STRUCTURE II LABORATORYCS6311- PROGRAMMING & DATA STRUCTURE II LABORATORY
CS6311- PROGRAMMING & DATA STRUCTURE II LABORATORY
 
Assignment#1
Assignment#1Assignment#1
Assignment#1
 
Kirti Kumawat, BCA Third Year
Kirti Kumawat, BCA Third YearKirti Kumawat, BCA Third Year
Kirti Kumawat, BCA Third Year
 
Reshma Kodwani , BCA Third Year
Reshma Kodwani , BCA Third YearReshma Kodwani , BCA Third Year
Reshma Kodwani , BCA Third Year
 
C++ L01-Variables
C++ L01-VariablesC++ L01-Variables
C++ L01-Variables
 
C++ Basics
C++ BasicsC++ Basics
C++ Basics
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
 
Computer Investigatory Project
Computer Investigatory ProjectComputer Investigatory Project
Computer Investigatory Project
 
Railway reservation(c++)
Railway reservation(c++)Railway reservation(c++)
Railway reservation(c++)
 
C++ Programs
C++ ProgramsC++ Programs
C++ Programs
 

Recently uploaded

The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdf
YibeltalNibretu
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 

Recently uploaded (20)

Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
 
B.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdfB.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdf
 
Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdf
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resources
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 

Cs investrigatory project

  • 1. KENDRIYA VIDYALAYA No.2 THIRUPPARANKUNDRAM In Accordance With CBSE AISSCE 2014- 2015RAILWAY RESERVATION
  • 2. Done by Name: r.sridhar Roll no: 4611810 KENDRIYA VIDYALAYA No.2 THIRUPPARANKUNDRAM BONAFIDE CERTIFICATE This is to certify that this project entitled as “RAILWAY RESERVATION” is a record of Bonafide work carried out by R.SRIDHAR and in the fulfilment of all requirements in computer as prescribed by CBSE AISSCE 2014-2015 for class XII in school KENDRIYA VIDYALAYA THIRUPARANKUNDRAM, MADURAI-625005.
  • 3. Date: internal examiner Principal : external examiner ACKNOWLEDGEMENT At the outset, I would like to express my humble thanks to the god almighty, for the kind grace showed on us to complete the project successfully. I would also like to express my sincere thanks to our Principal, Smt.GEETHA KUMARI for rendering necessary facilities to our project.
  • 4. I also convey our immense gratititude to our academic project guide Smt. K.SHANMUGA PRIYA for her wonderful suggestions, Constant support, ideas and extraordinary guidance throughout the project. I would also like to convey our heartfelt thanks to all the staff members of my school, my friends and my parents for extending their support and encouraged me a lot to complete my project work on time.
  • 5. Contents 1. C++ INTRODUCTION.. . . . . . . . . . . . . 2. SYSTEM ENVIRONMENT.. . . . . . . . . . . 3. SYNOPSIS. . . . . . . . . . . . . 4. CODING . . . . . . . . . .. . . . . . . . . . . . . . . . . 5. OUTPUT SCREENS. . . . . . . . . . . . . . . . . . . 6. CONCLUSION. . . . . . . . . . . . . . . . . . . . . . 7. BIBLIOGRAPHY. . . . . . . . . . . . . . . . . . . . .
  • 6. C++ INTRODUCTION: C++ IS A STATICALLY TYPED, FREE-FORM, MULTI-PARADIGM, COMPILED, GENERAL PURPOSE PROGRAMMING LANGUAGE. IT IS REGARED AS AN INTERMEDIATE-LEVEL LANGUAGE, AS IT COMPRISES A COMBINATION OF BOTH HIGH LEVEL AND LOW LEVEL LANGUAGE FEATURES. DEVELOPED BY BJARNE STROUSTRUPSTARTING IN 1979 AT BELL LABS, IT ADDS OBJECT ORIENTED FEATURES, SUCH AS CLASSES, AND OTHER ENHANCEMENTS TO THE C PROGRAMMING LANGUAGE. ORIGINALLY NAMED C WITH CLASSES, THE LANGUAGE WAS RENAMED C++ IN 1983, AS A PUN INVOLVING THE INCREMENT OPERATOR. C++ IS ONE OF THE MOST POPULAR PROGRAMMING LANGUAGES AND IS IMPLEMENTED ON A WIDE VARIETY OF HARDWARE AND OPERATING SYSTEM PLATFORMS.AS AN EFFICIENT COMPILER TO NATIVE CODE,ITS APPLICATION DOMAINS INCLUDE SYSTEMS SOFTWARE, APPLICATION SOFTWARE,DEVICE DRIVERS,EMBEDDED SOFTWARE,HIGH PERFORMANCE SERVER AND CLIENT APPLICATIONS,AND ENTERTAINMENT SOFTWARE. SEVERAL GROUPS PROVIDE BOTH FREE AND PROPRIETARY C++ COMPILER SOFTWARE, INCLUDING THE GUN PROJECT, MICROSOFT, INTEL AND EMBARCADERO TECHNOLOGIES.C++ HAS GREATLY INFLUENCED MANY OTHER POPULAR PROGRAMMING LANGUAGES, MOST NOTABLY C++AND JAVA. C++ IS ALSO USED FOR HARDWARE DESIGN, WHERE THE DESIGN IS INITIALLY DESCRBED IN C++, THEN ANALYZED, ARCHITECTURALLY CONSTRAINED AND SCHEDULED TO CREATE A REGISTER TRANSFER LEVEL HARDWARE DESCRIPTION LANGUAGE VIA HIGH LEVEL SYNTHESIS.
  • 7. OBJECTS: C++ INTRODUCES OBJECT ORIENTED PROGRAMMIMG (00P) FEATURES TO C. IT OFFERS CLASSES, WHICH PROVIDE THE FOUR FERTURES COMMONLY PRESENT IN OOP LANGUAGES: ABSTRACTION, ENCAPSULATION, INHERITANCE, AND POLMORPHISM. ONE DISTINGUISHING FEATURE OF C++ CLASSES COMPARED TO CLASSES IN OTHER PROGRAMMING LANGUAGES IS SUPPORT FOR DETEMINISTIC DESTRUCTORS, WHICH IN TURN PROVIDE SUPPORT FOR THE RESOURCE ACQUISITION IS INITIALIZATION CONCEPT.
  • 8. SYSTEM ENVIRONMENT: 3.1. HARDWARE CONFIGURATION: PROCESSOR : INTEL i3@512GHz MONITORS : 800*600 MINIUM RESOLUTIONS AT 256 COLORS MINIMUM RAM : 2GB HARD DISK : 250GB KEYBOARD : TVS 140 MOUSE : LOGITECH 3.2. SOFTWARE CONFIGURATION: LANGUAGE : C++ PROGRAMMING LANGUAGE OPERATING SYSTEM : WINDOWS ‘XP’.
  • 9. SYNOPSIS RAILWAY RESERVATION IS BASIC AND SAMPLE OF RESERVING TICKETS AND CANCELLATION OF RESERVED TICKETS DESCRIPTION: THIS C++ PROGRAM ON RAILWAY RESERVATION IS A SIMPLE TEXT BASE PROGRAM. WE HAVE USED PROCEDURE ORIENTED METHOD TO DESIGN THIS PROGRAM. THIS PROGRAM IS WITH GRAPHICS TO KEEP PROGRAM FOR BEGINNERS. PASSENGERS HAS BEEN ASKED FOR ID AND PASSWORD FOR PROTECTION .WE HAVE GIVEN USER FRIENDLY MENUS TO ENQUIRE, RESERVE, CANCEL THE RAILWAY TICKETS. IN THIS PROJECT, WE HAVE USED PROGRAMMING CONCEPT LIKE IF LOOP, USER DEFINED FUNCTION, LIBRARY FUNCTION.
  • 10. SOURCE CODE //administrator password is ‘abc’ #include<iostream.h> #include<conio.h> #include<stdlib.h> #include<string.h> #include<stdio.h> #include<time.h> #include<iomanip.h> #include<fstream.h> //Global variables char f[2]="f"; //"f" for first-class char s[2]="s"; //"s" for second-class int addr,ad,flag=1,f1,d,m,i,amt; //amt -> amount float tamt; //tamt -> total_amount //First class : "login" class login { public:
  • 11. char id[20]; char pass[10]; //pass -> password char *password; void getid() { cout<<"Enter ID : "; gets(id); password=getpass("Enter password : "); strcpy(pass,password); } void displayid() { cout<<"User ID Information"<<endl<<endl; cout<<"ID : ";puts(id);cout<<endl; cout<<"Password : ";puts(pass); } }; //Second class : "detail" of train class detail { public: int tno; //tno -> Train Number char tname[30]; //tname -> Train Name char bp[20]; //bp -> Boarding Point char dest[20]; //dest -> Destination int c1,c1fare; //c1 -> First class c1fare -> First class fare int c2,c2fare; //c2 -> Second class c2fare -> Second class fare
  • 12. int d,m,y; //d -> date , m -> month , y -> year void getdetail() { clrscr(); cout<<"Enter the details as follows"<<endl<<endl; cout<<"Train number : ";cin>>tno; cout<<"Train name : ";gets(tname); cout<<"Boarding point : ";gets(bp); cout<<"Destination point : ";gets(dest); cout<<"No of seats in first class "<<endl; cout<<"and fare per ticket : "; cin>>c1>>c1fare; cout<<"No of seats in second class "<<endl; cout<<"and fare per ticket : "; cin>>c2>>c2fare; cout<<"Date of travel(in dd/mm/yy) : ";cin>>d>>m>>y; } void displaydetail() { cout<<"---------------------------------"; cout<<"-----------------------------------------------"; cout<<"Tr_No | Tr_Name | Start | Destin. |"; cout<<" FC_se | SC_se | Fr_FC | Fr_SC | Date of Jo."; cout<<"n----------------------------------";
  • 13. cout<<"----------------------------------------------n"; cout<<tno<<" "<<tname<<" "<<bp<<" "<<dest<<" "<<c1<<" "<<c2; cout<<" "<<c1fare<<" "<<c2fare<<" "<<d<<"/"<<m<<"/"<<y<<endl<<endl; cout<<"----------------------------------"; cout<<"----------------------------------------------"; } }; //Third class : "reser" for reservation class reser : public detail { public: int pnr; //pnr -> Passenger Name Record int tno; //tno -> Train Number char tname[30]; //tname -> Train Name char bp[20]; char dest[20]; char pname[10][100];//pname -> Passenger Name int age[20]; //age -> Age of passenger char clas[10]; int nosr; //nosr -> No. of seats reserved int i; //i -> Counter variable int d,m,y;
  • 14. int con; //con -> Concession amount float amc; //amc -> Amount pay to customer void getresdet(); void displayresdet(); }; void reser::getresdet() //getresdet -> get reservation details { clrscr(); cout<<"Enter the details as follows"<<endl<<endl; cout<<"Train number : ";cin>>tno; cout<<"Train name : ";gets(tname); cout<<"Boarding point : ";gets(bp); cout<<"Destination point : ";gets(dest); cout<<"No of seats required : ";cin>>nosr; for(i=0;i<nosr;i++) { cout<<"Passenger ("<<i+1<<") name : ";gets(pname[i]); cout<<"Passenger ("<<i+1<<") age : ";cin>>age[i]; } cout<<"Enter the class"<<endl; cout<<"'f' for first class "<<endl; cout<<"'s' for second class : ";gets(clas); cout<<"Date of travel : ";cin>>d>>m>>y; cout<<"nnEnter the concession category from belown";
  • 15. cout<<"1.Militaryn2.Senior citizenn"; cout<<"3.Children(below 5 yrs)n4.Nonen"; cout<<"Enter your choice : ";cin>>con; } void reser::displayresdet() // Display reservation details { cout<<endl; cout<<"-----------------------------------------------------n"; cout<<" RESERVATION STATUS n"; cout<<"-----------------------------------------------------n"; cout<<"PNR number : "<<pnr<<endl; cout<<"Train number : "<<tno<<endl; cout<<"Train name : ";puts(tname); cout<<"Boarding point : ";puts(bp); cout<<"Destination point : ";puts(dest); cout<<"Number of seats reserved : "<<nosr<<endl; for(i=0;i<nosr;i++) { cout<<"Passenger "<<i+1<<" name : ";puts(pname[i]); cout<<"Passenger "<<i+1<<" age : "<<age[i]<<endl; } cout<<"Your class : ";puts(clas); cout<<"Date of reservation : "<<d<<"/"<<m<<"/"<<y; cout<<"nYour concession category : "<<con; cout<<"nYou must pay : "<<amc<<endl;
  • 16. cout<<"------------------------------------------------------n"; cout<<" END OF RESERVATION DETAILS OF PASSENGER n"; cout<<"------------------------------------------------------n"; } //Fourth class : "canc" - cancellation of reserved ticket class canc : public detail { public: int pnr; int tno; char tname[100]; char bp[20]; char dest[20]; char pname[10][100]; int age[20]; int i; char clas[10]; int nosc; int d,m,y; float amr; void getcancdet() { cout<<"nnEnter the details as followsn";
  • 17. cout<<"nPNR number : ";cin>>pnr; cout<<"nDate of cancellation : ";cin>>d>>m>>y; } void displaycancdet(); }; void canc::displaycancdet() { cout<<"---------------------------------------------n"; cout<<" DISPLAY OF CANCELLATION n"; cout<<"---------------------------------------------n"; cout<<"PNR number : "<<pnr<<endl; cout<<"Train number : "<<tno<<endl; cout<<"Train name : ";puts(tname); cout<<"Boarding point : ";puts(bp); cout<<"Destination point : ";puts(dest); cout<<"Your class : ";puts(clas); cout<<"No of seats has been cancelled : "<<nosc<<endl; for(i=0;i<nosc;i++) { cout<<"Passenger name : ";puts(pname[i]); cout<<"Passenger age : "<<age[i]<<endl; } cout<<"Date of cancellation : "<<d<<"/"<<m<<"/"<<y<<endl; cout<<"You can collect : Rs."<<amr<<endl; cout<<"---------------------------------------------n";
  • 18. cout<<" END OF CANCELLATION n"; cout<<"---------------------------------------------n"; } //User-Defined Function(UDF) declaration part void manage(); void can(); void user(); void database(); void res(); void reserve(); void displaypassdetail(); void cancell(); void enquiry(); //main function starts void main() { int ch; do { clrscr(); cout<<"-----------------------------------------------------------n";
  • 19. cout<<" WELCOME TO ONLINE RAILWAY RESERVATION SYSTEM n"; cout<<"-----------------------------------------------------------n"; cout<<"nn-----------------------------------------------------------n"; cout<<" MAIN MENU n"; cout<<"-----------------------------------------------------------n"; cout<<"nn1. Admin mode nn2. User mode nn3. Exitn"; cout<<"nEnter your choice : "; cin>>ch; cout<<endl; switch(ch) { case 1: database(); break; case 2: user(); break; case 3: exit(0); } }while(ch<=3); getch();
  • 20. } //User-Defined Function(UDF) definition void database() //Database function for administrator { char *password; char *pass="abc"; password=getpass("nEnter the admininistrator password : "); detail a; fstream f; int ch; char c; if(strcmp(pass,password)!=0) { cout<<"nEnter the password correctlyn"; cout<<"You are not permitted to login this moden"; getch(); goto h; } if(strcmp(pass,password)==0) { char c; do {
  • 21. clrscr(); cout<<"n-----------------------------------------------------n"; cout<<" ADMINISTRATOR MENU n"; cout<<"-----------------------------------------------------n"; cout<<"nn1. Add detailsn"; cout<<"n2. Display detailsnn3. User managementn"; cout<<"n4. Display passenger detailsnn5. Return to main menun"; cout<<"nEnter your choice : "; cin>>ch; cout<<endl; switch(ch) { case 1: f.open("t.txt",ios::in|ios::out|ios::binary|ios::app); do { a.getdetail(); f.write((char *) & a,sizeof(a)); cout<<"nnDo you want to add one more record?n"; cout<<"y-for Yesnn-for Non"; cout<<"Your answer : "; cin>>c; }while(c=='y'); f.close(); break;
  • 22. case 2: f.open("t.txt",ios::in|ios::out|ios::binary|ios::app); f.seekg(0); while(f.read((char *) & a,sizeof(a))) { a.displaydetail(); } getch(); f.close(); break; case 3: manage(); break; case 4: displaypassdetail(); break; } }while(ch<=4); f.close(); } h: }
  • 23. void reserve() { int ch; do { clrscr(); cout<<"1. Reservenn2. Return to the main menun"; cout<<"nEnter your choice : "; cin>>ch; cout<<endl; switch(ch) { case 1: res(); break; } }while(ch==1); getch(); } void res() { detail a; reser b; fstream f1,f2;
  • 24. time_t t; f1.open("t.txt",ios::in|ios::out|ios::binary); f2.open("p.txt",ios::in|ios::out|ios::binary|ios::app); int ch; b.getresdet(); while(f1.read((char *) &a,sizeof(a))) { if(a.tno==b.tno) { if(strcmp(b.clas,f)==0) { if(a.c1>=b.nosr) { amt=a.c1fare; addr=f1.tellg(); ad=sizeof(a.c1); f1.seekp(addr-(7*ad)); a.c1=a.c1-b.nosr; f1.write((char *) & a.c1,sizeof(a.c1)); if(b.con==1) { cout<<"nConcession category : MILITARY PERSONNELn"; b.amc=b.nosr*((amt*50)/100); } else if(b.con==2)
  • 25. { cout<<"nConcession category : SENIOR CITIZENn"; b.amc=b.nosr*((amt*60)/100); } else if(b.con==3) { cout<<"nConcession category : CHILDERN BELOW FIVEn"; b.amc=0.0; } else if(b.con==4) { cout<<"nYou cannot get any concessionn"; b.amc=b.nosr*amt; } srand((unsigned) time(&t)); b.pnr=rand(); f2.write((char *) & b,sizeof(b)); b.displayresdet(); cout<<"------------------------------------------------------n"; cout<<" YOUR TICKET HAS BEEN RESERVED n"; cout<<"------------------------------------------------------n"; } else { cout<<"-----------------------------------------------------n";
  • 26. cout<<" SORRY REQUESTED SEATS ARE NOT AVAILABLE n"; cout<<"-----------------------------------------------------n"; } } else if(strcmp(b.clas,s)==0) { if(a.c2>=b.nosr) { amt=a.c2fare; addr=f1.tellg(); ad=sizeof(a.c2); f1.seekp(addr-(5*ad)); a.c2=a.c2-b.nosr; f1.write((char *) & a.c2,sizeof(a.c2)); if(b.con==1) { cout<<"nConcession category : MILITARY PRESONNELn"; b.amc=b.nosr*((amt*50)/100); } else if(b.con==2) { cout<<"nConcession category : SENIOR CITIZENn"; b.amc=b.nosr*((amt*60)/100); } else if(b.con==3)
  • 27. { cout<<"nConcession category : CHILDERN BELOW FIVEn"; b.amc=0.0; } else if(b.con==4) { cout<<"nYou can not get any concessionn"; b.amc=b.nosr*amt; } f2.write((char *) & b,sizeof(b)); b.displayresdet(); cout<<"-----------------------------------------------------n"; cout<<" YOUR TICKET HAS BEEN RESERVED n"; cout<<"-----------------------------------------------------n"; } else { cout<<"--------------------------------------------------------n"; cout<<" SORRY REQIRED SEATS ARE NOT AVAILABLE n"; cout<<"--------------------------------------------------------n"; } } getch(); goto h;
  • 28. } else { flag=0; } } if(flag==0) { cout<<"n-------------------------------------------------------n"; cout<<" WRONG TRAIN NUMBER n"; cout<<"-------------------------------------------------------n"; cout<<" ENTER THE TRAIN NO. FROM DATABASE n"; cout<<"-------------------------------------------------------n"; } f1.close(); f2.close(); getch(); h: } void displaypassdetail() { fstream f; reser b; f.open("p.txt",ios::in|ios::out|ios::binary); f.seekg(0);
  • 29. while(f.read((char *) & b,sizeof(b))) { b.displayresdet(); } f.close(); getch(); } void enquiry() { fstream f; f.open("t.txt",ios::in|ios::out|ios::binary); detail a; while(f.read((char *) & a,sizeof(a))) { a.displaydetail(); } getch(); } void cancell() { detail a; reser b; canc c; fstream f1,f2,f3; f1.open("t.txt",ios::in|ios::out|ios::binary);
  • 30. f2.open("p.txt",ios::in|ios::out|ios::binary); f3.open("cn.txt",ios::in|ios::out|ios::binary); clrscr(); cout<<"n-----------------------------------------------------n"; cout<<" CANCELLATION MENU n"; cout<<"-----------------------------------------------------n"; c.getcancdet(); while(f2.read((char *) & b,sizeof(b))) { if(b.pnr==c.pnr) { c.tno=b.tno; strcpy(c.tname,b.tname); strcpy(c.bp,b.bp); strcpy(c.dest,b.dest); c.nosc=b.nosr; for(int j=0;j<c.nosc;j++) { strcpy(c.pname[j],b.pname[j]); c.age[j]=b.age[j]; } strcpy(c.clas,b.clas); if(strcmp(c.clas,f)==0) { while(f1.read((char *) & a,sizeof(a)))
  • 31. { if(a.tno==c.tno) { a.c1=a.c1+c.nosc; d=a.d; m=a.m; addr=f1.tellg(); ad=sizeof(a.c1); f1.seekp(addr-(7*ad)); f1.write((char *) & a.c1,sizeof(a.c1)); tamt=b.amc; if((c.d==d)&&(c.m==m)) { cout<<"You are cancelling at the date of departure."<<endl; c.amr=tamt-((tamt*60)/100); } else if((c.m==m) && (c.d<d)) { cout<<"You are cancelling at the month of departure."<<endl; c.amr=tamt-((tamt*50)/100); } else if(m>c.m) { cout<<"You are cancelling "<<m-c.m<<" month before the date of departure."<<endl;
  • 32. c.amr=tamt-((tamt*20)/100); } else { cout<<"You are cancelling after the departure."<<endl; cout<<"Your request cannot be completed."<<endl; } fstream fp2; fp2.open("Temp.dat",ios::out); f2.seekg(0,ios::beg); while(f2.read((char*)&b,sizeof(b))) { if(b.pnr!=c.pnr) { fp2.write((char*)&b,sizeof(b)); } } fp2.close(); remove("p.txt"); rename("Temp.dat","p.txt"); c.displaycancdet(); goto h; } } }
  • 33. else if(strcmp(c.clas,s)==0) { while(f1.read((char *) & a,sizeof(a))) { if(a.tno==c.tno) { a.c2=a.c2+c.nosc; d=a.d; m=a.m; addr=f1.tellg(); ad=sizeof(a.c2); f1.seekp(addr-(5*ad)); f1.write((char *) & a.c2,sizeof(a.c2)); tamt=b.amc; if((c.d==d)&&(c.m==m)) { cout<<"You are cancelling at the date of departure."<<endl; c.amr=tamt-((tamt*60)/100); } else if((c.m==m) && (c.d<d)) { cout<<"You are cancelling at the month of departure."<<endl; c.amr=tamt-((tamt*50)/100); } else if(m>c.m)
  • 34. { cout<<"You are cancelling "<<m-c.m<<" month before the date of departure."<<endl; c.amr=tamt-((tamt*20)/100); } else { cout<<"You are cancelling after the departure."<<endl; cout<<"Your request cannot be completed."<<endl; } fstream fp2; fp2.open("Temp.dat",ios::out); f2.seekg(0,ios::beg); while(f2.read((char*)&b,sizeof(b))) { if(b.pnr!=c.pnr) { fp2.write((char*)&b,sizeof(b)); } } fp2.close(); remove("p.txt"); rename("Temp.dat","p.txt"); c.displaycancdet(); goto h;
  • 35. } } } } else { flag=0; } } h: if(flag==0) { cout<<"nEnter the correct PNR number.n"; } f1.close(); f2.close(); f3.close(); getch(); } void can() { int ch; do {
  • 36. clrscr(); cout<<"n----------------------------------------------------n"; cout<<" CANCELLATION MENU n"; cout<<"----------------------------------------------------n"; cout<<"nn1. Cancelnn2. Return to the main menun"; cout<<"nEnter your choice:"; cin>>ch; cout<<endl; switch(ch) { case 1: cancell(); break; } }while(ch==1); getch(); } void user() { login a; int ch; clrscr(); cout<<"n-----------------------------------------------------n"; cout<<" USER MENU n";
  • 37. cout<<"-----------------------------------------------------n"; char *password; fstream f; f.open("id.txt",ios::in|ios::out|ios::binary); char id[100]; cout<<"nnEnter your ID : "; gets(id); password=getpass("nEnter your password : "); while(f.read((char *) & a,sizeof(a))) { if((strcmp(a.id,id)==0)&&(strcmp(a.pass,password)==0)) { do { clrscr(); cout<<"nn1. Reserve a ticketnn2. Cancel a ticket"; cout<<"nn3. Enquirynn4. Return to the main menun"; cout<<"nEnter your choice : "; cin>>ch; cout<<endl; switch(ch) { case 1: reserve(); break;
  • 38. case 2: cancell(); break; case 3: enquiry(); break; } }while(ch<=3); goto j; } else { d=1; } } if(d==1) { cout<<"nEnter user ID and password correctlyn"; } getch(); j: } void manage()
  • 39. {int ch; fstream f; char c; login a; clrscr(); cout<<"---------------------------------------------------------n"; cout<<" WELCOME TO THE USER MANAGEMENT MENU n"; cout<<"---------------------------------------------------------n"; do { cout<<"nn1. Add ID details of user n"; cout<<"n2. Display details of IDnn3. Return to the main menun"; cout<<"nEnter your choice : "; cin>>ch; cout<<endl; switch(ch) { case 1: f.open("id.txt",ios::in|ios::out|ios::binary|ios::app); do { a.getid(); f.write((char *) & a,sizeof(a)); cout<<"nnDo you want to add one more record>?n";
  • 40. cout<<"y-Yesnn-Non"; cout<<"Your answer : "; cin>>c; }while(c=='y'); f.close(); break; case 2: f.open("id.txt",ios::in|ios::out|ios::binary); f.seekg(0); while(f.read((char *) & a,sizeof(a))) { a.displayid(); } f.close(); break; } }while(ch<=2); getch(); }
  • 45. CONCLUSION THIS PROJECT MEETS THE REQUIREMENTS SPECIFICATION. IT GIVES LOGICAL SOLUTION FOR LONG TIME PROBLEM ON RESERVING TRAIN TICKETS AND CANCELLATION OF TICKETS BOOKED. AND FINALLY IT SUCCESSFULLY RUNS AND REPORTS ARE GENERATED IN A NEAT MANNER. AS AIMED IT REDUCES LOT OF PAPER REFERENCE AND USER FRIENDLY. THE PROGRAMMING TECHNIQUE USED IN THE DESIGN OF THE SYSTEM PROVIDES A SCOPE FOR FURTHER EXPANSION AND IMPLEMENTATION OF ANY CHANGES, WHICH MAY OCCUR IN FUTURE.
  • 46. BIBLIOGRAPHY 1. http://en.wikipedia.org 2. Computer Science with c++ by Sumita Arora 3. Object oriented programming by Robert Lafore 4. www.cppforschool.com 5. www.bOtskOOl.com