Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 22

Project file on

Railway reservation system

SESSION : 2019-20

NAME –Hemant Rajput


CLASS – 12 th
SECTION -Science
SUBJECT - Computer Science
SUBMITTED TO – Rohit Sir
CERTIFICATE

This is certify that this project file


entitled “Railway Reservation
System” submitted to COMPUTER
DEPARTMENT, GYAN DEEP
SHIKSHA BHARATI
MATHURA is a bonafide record
of work done by HEMANT under
my supervision during the
academic year 2019-2020.

Internal Examiner External Examiner

------------------------ ------------------------
ACKNOWLEDGEMENT

I take this opportunity to express


my profound gratitude and deep
regards to my mentor MR. Rohit
Agarwal for his exemplary
guidance, monitoring and constant
encouragement throughout the
course of this project. The blessing,
help and guidance given by him
time to shall carry me a long way
in the journey of life on which I
am about to embark.
CONTENTS

1. Introduction to Project

2. Introduction to C++ &


Benefits

3. Coding

4. Output Screens

5. Bibliography
Introduction to Project
This project is a simple
console application built
without the use of graphics.
Named railway reservation
system project in C++, this
program features two modes,
password protection and some
basic file handling operations
to add and display train
inquiry and reservation
records.
Features:
1. Administrator mode: There are two modes in this
project – the administrator mode and the user mode.
For the first time you have to create Users from the
Admin mode. Once users are created, you can use the
same user again and again, and they will be stored in
separate files.

In Admin mode, you can create detail database, add


details, display details, perform user management
functions and display passenger details.

2. User mode: As aforementioned, at first you need to go


to the administrator mode and create users. After that, you
can use these users as you wish, and the information
related to them will be recorded in separate files. In the
user mode, you can create id database, add details and
display details.

3. Train and Reservation details: In this railway


reservation system project in C++, users can get both the
train details and the train reservation details. The details to
be provided for train are train no., train name, boarding
point, destination point, no. of seats in first class and fare
per ticket, no. of seats in second class and fare per ticket
and date of travel.
And, in case of reservation details, the information to be
provided are train no., train name, boarding point,
destination point, no. of seats required, seat class
specification, date of reservation, passenger category and
amount to be paid. According to the no. of seats, additional
information – passenger name and passenger age are to
be provided. The passenger category is divided as:
military, senior citizen, children and none.

4. Cancel reservation: It is somewhat similar to the


feature mentioned above. This feature requires the date of
cancellation in this railway reservation system project in
C++. Then cancellation details can be displayed; the
details here include train no., train name, boarding point,
destination point, passenger class, no. of seats to be
cancelled, passenger name and age, date of cancellation
and the amount to be collected back.
Introduction to C++
C++ is the language which is used everywhere but

mainly in systems programming and embedded systems.

Here system programming means for developing the

operating systems or drivers that interface with

Hardware. Embedded system means things that are

automobiles, robotics, and appliances. C++ is having

higher or rich community and developers, which helps

in the easy hiring of developers and online solutions

easily.

Uses of C++ is referred to as the safest language because

of its security and features. It is the first language for

any developer to start, who is interested in working in

programming languages. It is easy to learn, as it is pure

concept based language. Its syntax is very simple, which

makes it easy to write or develop and errors can be


easily replicated. Before using any other language,

programmers preferred to learn C++ first and then they

used other languages. But most of the developers try to

stick with C++ only because of its wide variety of usage

and compatibility with multiple platforms and

software.

Benefits to Use C++

1. C++ program is useful for low level

programming language and very efficient for

general purposes , It offers performance and

memory efficiently.

2. It offers high level abstraction , in the language

of the problem domain , C++ program is

compatible with C , It uses reusability of code

and it uses inheritance , polymorphism .


3. C++ program uses the object where the objects

are real time entities , It is a container of

objects .

4. It offers reusability of codes , In C++ , the

functions and variables can acquire the feature

of its parents , In C++ , function can be

overloaded and override and C++ can use

encapsulation .

5. C++ program can support unions and structures

that are a combination of stand-alone and put

files together.

6. The global data and global functions are used

with in C++ that aren’t used in many other high

level languages in the computer sciences and it

is a great advantage to the programming

languages .
CODING
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<process.h>

char from[30],to[30];
void detail()
{
cout<<"From"<<endl;
gets(to);
cout<<"To"<<endl;
gets(from);
}
class railways
{
char station[30];
unsigned int distance;
float fare;
public:
void ad_data()
{
cout<<"Enter Railway Station name"<<endl;
gets(station);
cout<<"enter its distance from Jammu
Tawi"<<endl; cin>>distance;
}
void amount(int a,int b,int c)
{
cout<<"total distance="<<fabs((a-b))<<"\ncharges
per/km="<<c; fare=fabs((a-b))*c;
cout<<"\nticket cost ="<<fare;
}
unsigned int dist()
{
return distance;
}
Char* station_v()
{
return station ;
}

void modify()
{
cout<<"\nEnter new railway
station\n"; gets(station);
cout<<"\nenter its distance from
jammu tawi\n"; cin>>distance;
}
}tr;
void main()
{
clrscr();
unsigned int per_km=5,choice,
d1=0,d2=0,i;
char station_searched[30];
while(1)
{
clrscr();
cout<<"\n\t\t\tWELCOME TO INDIAN RAILWAYS\n";
for(i=0;i<80;i++)
{
cout<<"-";
}
cout<<"Enter your choice \n\t1:->Add new railway
station\n\t2:->Book ticket"<<endl;
cout<<"\t3:->Change per km rates\n\t4:->modify
database of train\n\t5:->exit\n";
for(i=0;i<80;i++)
{
cout<<"-";
}
cin>>choice;
while(choice==1)
{
ofstreamof1("train.dat",ios::binary|ios::app);
tr.ad_data();
of1.write((char*)&tr,sizeof(tr));
of1.close();
break;
}
while(choice==2)
{
ifstreamof1("train.dat",ios::binary);
detail();
while(of1)
{
of1.read((char*)&tr,sizeof(tr));
if(0==stricmp(from,tr.station_v()))
{
d1=tr.dist();
}
if(0==stricmp(to,tr.station_v()))
{
d2=tr.dist();
}
if(d1 && d2)
{
tr.amount(d1,d2,per_km);
getch();
break;
}
if(of1.eof())
{
cout<<"\nstations not found check your
spelling\n";
getch();
}
}
of1.close();
break;
}
if(choice==3)
{
cout<<"Enter new per km rates";
cin>>per_km;
}
if(choice==4)
{
cout<<"enter the railway station to be changed";
gets(station_searched);
ifstream f1("train.dat",ios::binary);
while(f1 )
{
f1.read((char*)&tr,sizeof(tr));

long pos=f1.tellg();

if(0==strcmp(station_searched,tr.station_v()))

{
f1.seekg((-1*sizeof(tr),ios::cur));

tr.modify();

f1.close();

ofstream f1("train.dat",ios::app);

f1.seekp(pos,ios::beg);

f1.write((char*)&tr,sizeof(tr));

cout<<"record modified";

f1.close();

break;

else if(f1.eof())
{

cout<<"\nStation not found\n";

getch();}

if(choice==5)

cout<<"\nTHANK YOU FOR USING INDIAN

RAILWAYS ";

getch();

exit(0);

if(choice!=1&&choice!=2&&choice!=3&&choice!=4

&&choice!=5)

{
cout<<"entered wrong choice PROGRAM IS

ABORTING!!!!!!";

getch();

exit(0);

getch();

}
OUTPUT SCREENS

1. WELCOME SCREEN

2. ADD NEW RAILWAY STATION


3. TO BOOK TICKETS

4. TO CHANGE PER KM RATES


5. TO MODIFY DATABASE OF TRAIN

6. EXIT SCREEN
Bibliography
Books :-

 “Introduction to C++” by Sumita


Arora.

 “Let us C” by A.K Sharma.

 “C++ Complete Reference” by Bjarne.

Websites :-

Source and other Information :-

 www.cprojects.com
 www.wikipedia.org

You might also like