You are on page 1of 20

INTRODUCTION

Today one cannot afford to rely on the fallible


human beings of be really wants to stand
against todays merciless competition where
not to wise saying to err is human no longer
valid, its out dated to rationalize your mistake.
So, to keep pace with time, to bring about the
best result without malfunctioning and greater
efficiency so to replace the unending heaps of
flies with a much sophisticated hard disk of the
computer. One has to use the data
management software. Software has been an
ascent in atomization various organizations.
Many software products working are now in
markets, which have helped in making the
organizations work easier and efficiently. Data
management initially had to maintain a lot of
ledgers and a lot of paper work has to be done
but now software product on this organization
has made their work faster and easier. Now
only this software has to be loaded on the
computer and work can be done. This prevents
a lot of time and money. The work becomes
fully automated and any information regarding
the organization can be obtained by clicking
the button. Moreover, now its an age of
computers of and automating such an
organization gives the better look.
Page | 1

PROGRAM LOGIC
The program declares a structure user which stores data members of
character and float type, which stores first name, last name, gender,
email address, password and residential address. And a structure
ticket which stores data members of character, double, float and
integer type, which stores the name of the passenger, departure
station address, destination address, departure date, total travelling
distance, total amount refunded, age and gender.
The program declares a main function signin(), signup(),options(),
booking(), checkpnr(), cancel(), showinfo(), dispinfo(), randomdist()
(for randomize), randompnr()(for randomize) , randomberth()(for
randomize).The main function contains 1 data member of integer type
to store the choice made by the user. The signup() function is used to
enter the first name, last name, gender, email address, password and
residential address of the user, all this information is stored in the
file account1.dat. In the signin() function the user is asked to enter
the login details i.e. the email id and password of the user. If the
login details given by the user matches the detais stored in the
database the function options() is called. In options() function the
user is asked to enter his/her choice, to book a train or to check pnr
status or to cancel reservation or to display customer details or to
exit and accordingly booking(), checkpnr(), cancel() and dispinfo()
functions are invoked,all this is done using switch case . In Booking()
function. In checkpnr() function the user is asked to enter the pnr
number allotted to him\her. And the pnr number is checked with the
pnr number in the database and if the number matches with the
number in the database the information of the passenger is displayed
Page | 2

by calling the showinfo() function. In the function cancel() the the


user is asked to enter the pnr number allotted to him\her. And the
pnr number is checked with the pnr number in the database and if the
number matches with the number in the database the reservation is
cancelled and the information of the passenger is displayed. In the
function dispinfo() the user is asked to enter the login details i.e. the
email id and password of the user.If the login details given by the
user matches the detais stored in the database the details of the
passenger is displayed.

Page | 3

PROGRAM CODE
#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<fstream.h>
const float LOW=100;
const double LOW1=1000;
const int LOW2=1;
struct user
{
char fname[20];
char lname[20];
char gen[20];
char email[20];
char pass[20];
float ph;
char raddr[90];
};
user A;
struct ticket
{
char name[20],des[20],dep[20],date[10];
int age,pass,berth;
double pnr;
float trainno,fare,dist;
char gender[10];
}B;
void signin();
void signup();
void options();
void booking();
void checkpnr();
void cancel();
void showinfo();
void dispinfo();
int randomdist();
//for randomize
Page | 4

int randompnr();
//for randomize
int randomberth();
//for randomize
void main()
{
clrscr();
int choice;
cout<<" ENTER 1 to signin and 2 to signup \n::: ";
cin>>choice;
if(choice==1)
signin();
else if(choice==2)
signup();
getch();
}
void signin()
//for loging in
{
char mail[20],pas[20];
int ans,x=0;
fstream ob1;
ob1.open("account1.dat",ios::in);
cout<<":::: ENTER YOUR LOGIN DETAILS ::::\n";
cout<<"ENTER EMAIL ID: ";
gets(mail);
cout<<"ENTER PASSWORD: ";
gets(pas);
while(!ob1.eof())
{
if(!ob1.eof())
{
ob1.read((char*)&A,sizeof(A));
if(strcmp(mail,A.email)==0 && strcmp(pas,A.pass)==0)
{
if(x!=0)
break;
x++;
options();
}
}
}
if(x==0)
{
cout<<"E-mail account does not exist...";
cout<<"\n Press \n 1. to create a new account or \n2. to exit :";
cin>>ans;
if(ans==1)
{
Page | 5

signup();
}
}
ob1.close();
}
void signup()
//for creating account
{
fstream ob;
ob.open("account1.dat",ios::app);
cout<<":::: ENTER THE ITEMS ::::\n";
cout<<"Enter the first name :";
gets(A.fname);
cout<<"Enter the last name :";
gets(A.lname);
cout<<"Enter the gender
:";
gets(A.gen);
cout<<"Enter the email id :";
gets(A.email);
cout<<"Enter the password :";
cin>>A.pass;
cout<<"Enter the residential address:";
gets(A.raddr);
ob.write((char*)&A,sizeof(A));
ob.close();
cout<<"Account successfully created\n";
cout<<"Press any key to sign in...";
signin();
}
void options()
//for user choice
{
int choice;
char ans;
do
{
cout<<"Enter your choice: \n 1. Book train \n 2. Check pnr status \n 3. Cancel
reservation \n 4. Display customer details \n 5. Exit \n:::";
cin>>choice;
switch(choice)
{
case 1:
booking();
break;
case 2:
checkpnr();
break;
case 3:
Page | 6

cancel();
break;
case 4:
dispinfo();
break;
case 5:
exit(0);
default:
cout<<"WRONG CHOICE\n";
}
cout<<"\nDo you want to continue: ";
cin>>ans;
clrscr();
}while(ans=='y');
}
void booking()
//for booking ticket
{
clrscr();
int n,a,i,k;
float b,h,j,rpkm=5;
char e[20],f[20],g[10];
fstream ob;
ob.open("passenger.dat",ios::out);
cout<<"Enter the no. of passengers:";
cin>>n;
a=randompnr();
cout<<"===== PLEASE ENTER THE DETAIL CAREFULLY =====\n";
cout<<"Enter the train no.
: ";
cin>>b;
cout<<"Enter the departure station
: ";
gets(e);
cout<<"Enter the destination station
: ";
gets(f);
cout<<"Enter the departure date (dd/mm/yy) : ";
gets(g);
h=randomdist();
j=h*rpkm;
for(i=0;i<n;i++)
{
cout<<"\nDETAILS FOR PASSENGER ";
cout<<"\nEnter the name
: ";
gets(B.name);
cout<<"Enter the gender
: ";
gets(B.gender);
cout<<"Enter the age
: ";
cin>>B.age;
Page | 7

B.pnr=a+650000;
B.trainno=b;
strcpy(B.dep,e);
strcpy(B.des,f);
strcpy(B.date,g);
B.pass=n;
B.dist=h;
B.fare=j;
k=randomberth();
B.berth=k;
ob.write((char*)&B,sizeof(B));
}
showinfo();
}
void checkpnr()
{
double b;
int x=0;
ifstream ob;
ob.open("passeger.dat",ios::in);
cout<<"Enter te PNR to be searched:";
cin>>b;
while(!ob.eof())
{
ob.read((char*)&B,sizeof(B));
if(b==B.pnr && x==0)
{
x++;
showinfo();
}
else
{
cout<<"\n WRONG PNR";
}
}
ob.close();
}
void cancel()
//for cancelling ticket
{
double c;
ifstream ob;
ob.open("passeger.dat",ios::in);
ofstream ob1;
ob1.open("temp.dat",ios::in);
cout<<"Enter the PNR to be cancelled : ";
cin>>c;
Page | 8

while(!ob.eof())
{
int x=0;
ob.read((char*)&B,sizeof(B));
if(c==B.pnr && x==0)
{
cout<<"\nDETAILS OF THE CANCELLED RESERVATION:";
cout<<"\n PNR
: "<<B.pnr;
cout<<"\n Train No.
: "<<B.trainno;
cout<<"\n Departure
: "<<B.dep;
cout<<"\n Destination
: "<<B.des;
cout<<"\n Departure date
: "<<B.date;
cout<<"\n Total travelling distance : "<<B.dist<<"km";
cout<<"\n Total amount refunded
: Rs."<<B.fare-150;
cout<<"\n\n DETAILS FOR PASSENGER \n";
cout<<"\n Name
: "<<B.name;
cout<<"\n Gender
: "<<B.gender;
cout<<"\n Age
: "<<B.age;
x++;
break;
}
else
{
cout<<"\n WRONG PNR";
}
}
ob.close();
ob1.close();
remove("passenger.dat");
rename("temp.dat","passenger.dat");
}
int randomdist()
{
randomize();
float point=499,num=0;
for(int j=0;j<=1;j++)
{
num=LOW+random(point);
point--;
}
num=num;
return num;
}
int randompnr()
{
randomize();
Page | 9

double point=9999,num;
for(int j=0;j<=1;j++)
{
num=LOW+random(point);
point--;
}
return num;
}
int randomberth()
{
randomize();
float point=70,num=0;
for(int j=0;j<=1;j++)
{
num=LOW2+random(point);
point--;
}
num=num;
return num;
}
void showinfo()
//for displaying the ticket
{
int a,x=0;
a=randomdist();
ifstream ob;
ob.open("passenger.dat",ios::in);
cout<<"\n ============ YOUR BILLING DETAILS =========== \n";
while(!ob.eof())
{
ob.read((char*)&B,sizeof(B));
if(x==0)
{
cout<<"\n PNR
: "<<B.pnr;
cout<<"\n Train No.
: "<<B.trainno;
cout<<"\n Departure
: "<<B.dep;
cout<<"\n Destination
: "<<B.des;
cout<<"\n Departure date
: "<<B.date;
cout<<"\n Total travelling distance : "<<B.dist<<"km";
cout<<"\n Total fare
: Rs."<<B.fare;
cout<<"\n DETAILS FOR PASSENGER \n";
cout<<"\n Name
: "<<B.name;
cout<<"\n Gender
: "<<B.gender;
cout<<"\n Age
: "<<B.age;
cout<<"\n Berth allocated
: B2 "<<B.berth;
cout<<"\n--------------";
x++;
Page | 10

}
}
cout<<"\n===== THANK YOU AND HAVE A NICE JOURNEY =====\n";
ob.close();
}
void dispinfo()
//for displaying user information
{
char mail1[20],pas1[20];
int x=0;
fstream ob1;
ob1.open("account1.dat",ios::in);
cout<<":::: ENTER YOUR DETAILS ::::\n";
cout<<"ENTER EMAIL ID: ";
gets(mail1);
cout<<"ENTER PASSWORD: ";
gets(pas1);
while(!ob1.eof())
{
ob1.read((char*)&A,sizeof(A));
if(strcmp(mail1,A.email)==0 && strcmp(pas1,A.pass)==0 && x==0)
{
cout<<"\nFirst name
:"<<A.fname;
cout<<"\nLast name
:"<<A.lname;
cout<<"\nGender
:"<<A.gen;
cout<<"\nEmail id
:"<<A.email;
cout<<"\nPassword
:"<<A.pass;
cout<<"\nResidential address :"<<A.raddr;
x++;
}
}
}

Page | 11

OUTPUT SCREEN

Page | 12

Page | 13

VARIABLE

DESCRIPTION

VARIABL
E

DATATYPE

PURPOSE

fname

char

To store the first name of user

lname

char

To store the last name of user

gen

char

To store the gender

email

char

To store the email ID

pass

char

To store the password

ph

float

To store the phone number

Page | 14

raddr

char

To store the residential address

name

char

To store the name of passenger

des

char

To store the destination station

dep

char

To store the departure station

date

char

To store the date of journey

age

int

To store the age

berth

int

To store the berth number

pnr

double

trainno

float

To store the train number

fare

float

To store the fare

dist

float

To store the distance

gender

char

To store the gender

LOW

int

To store the random value

LOW1

float

To store the random value

LOW2

float

To store the random value

mail

char

To store the email ID

pas

char

To store the password

To store the PNR

Page | 15

ans

char

To store the user choice

rpkm

int

To store the rate per km

int

To store the random PNR

float

To store the train number

char

To store the departure station

char

To store the destination station

char

To store the date

float

To store the random distance

int

float

int

To store the berth number

int

To store the number of passengers

mail1

char

To check the entered Email ID

pas1

char

To check the enterd password

num

int

point

float

To carry on the loop


To store the fare

To store the number of passengers


To store the random value

Page | 16

FUNCTION
NAME

DESCRIPTION

signin()

RETURN
TYPE
void

PURPOSE
To login into account

signup()

void

To create a new account

options()

void

To enter the user choice

booking()

void

To book a ticket

checkpnr()

void

To check PNR status

cancel()

void

To cancel a ticket

showinfo()

void

To display the customers


information
Page | 17

dispinfo()

void

To display user information

randomdist()

int

To return random distance

randompnr()

int

To return random PNR

randomberth() int

To return random berth

UTILITY OF THE PROJECT


Now one can easily plan the journey comfortably as
the process is efficient and fast with being easy to
access. Reservations can be made through the
Indian railways site or at the ample reservation
centers all over the country. Also now there are
authorized agencies which provide reservation
facility on behalf of India railways and without
waiting in long line one can easily book a ticket.
The booking is done through E-Ticket issues which
have a PNR number of which one has to take a print
and just have to show at the station.

Page | 18

It not only provides reservation but


cancellation can also be done through this system
at ease and one can use a credit card to complete
the process.
This being a big step in terms of
improvement in the railway system it is widely
accepted across the country.

BIBLOGRAPHY
These are the following links which assist me at each and
every step in completing this project , without them I
was not be able to finish this important project:1.www.scribd.com
2.www.wikipedia.com
3.www.answers.com
4.www.askme.com
5.www.google.com

Page | 19

Instead of these useful websites , following books also


help me:
1.OBJECT ORIENTED PROGRAMMING WITH C++
BY SUMITA ARORA
2.OBJECT ORIENTED PROGRAMMING
BT ROBERT LAFORE

Page | 20

You might also like