cs investrigatory project

56
KENDRIYA VIDYALAYA No.2 THIRUPPARANKUNDRAM In Accordance With CBSE AISSCE 2014-2015 Done by RAILWAY RESERVATION

Upload: hgiuo

Post on 06-Aug-2015

59 views

Category:

Education


1 download

TRANSCRIPT

Page 1: Cs investrigatory project

KENDRIYA VIDYALAYA No.2

THIRUPPARANKUNDRAM

In Accordance With CBSE AISSCE 2014-2015

Done by

Name:r.sridhar

RAILWAY RESERVATION

Page 2: Cs investrigatory project

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

Page 3: Cs investrigatory project

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.

Page 4: Cs investrigatory project

Contents

1. C++ INTRODUCTION. . . . . . . . . . . . . .

2. SYSTEM ENVIRONMENT. . . . . . . . . . . .

3. SYNOPSIS. . . . . . . . . . . . .

4. CODING . . . . . . . . . .. . . . . . . . . . . . . . . . .

5. OUTPUT SCREENS. . . . . . . . . . . . . . . . . . .

6. CONCLUSION. . . . . . . . . . . . . . . . . . . . . .

7. BIBLIOGRAPHY. . . . . . . . . . . . . . . . . . . . .

Page 5: Cs investrigatory project

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.

Page 6: Cs investrigatory project

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.

Page 7: Cs investrigatory project

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’.

Page 8: Cs investrigatory project

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.

Page 9: Cs investrigatory project

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 : ");

Page 10: Cs investrigatory project

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;

Page 11: Cs investrigatory project

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<<"----------------------------------------------";

Page 12: Cs investrigatory project

}

};

//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();

};

Page 13: Cs investrigatory project

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<<"\n\nEnter the concession category from below\n";

cout<<"1.Military\n2.Senior citizen\n";

cout<<"3.Children(below 5 yrs)\n4.None\n";

cout<<"Enter your choice : ";cin>>con;

}

void reser::displayresdet() // Display reservation details

{

Page 14: Cs investrigatory project

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

Page 15: Cs investrigatory project

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<<"\n\nEnter the details as follows\n";

cout<<"\nPNR number : ";cin>>pnr;

cout<<"\nDate of cancellation : ";cin>>d>>m>>y;

}

void displaycancdet();

};

void canc::displaycancdet()

Page 16: Cs investrigatory project

{

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

Page 17: Cs investrigatory project

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<<"\n\n-----------------------------------------------------------\n";

cout<<" MAIN MENU \n";

cout<<"-----------------------------------------------------------\n";

Page 18: Cs investrigatory project

cout<<"\n\n1. Admin mode \n\n2. User mode \n\n3. Exit\n";

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

{

Page 19: Cs investrigatory project

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 correctly\n";

cout<<"You are not permitted to login this mode\n";

getch();

goto h;

}

if(strcmp(pass,password)==0)

{

char c;

do

{

clrscr();

cout<<"\n-----------------------------------------------------\n";

cout<<" ADMINISTRATOR MENU \n";

cout<<"-----------------------------------------------------\n";

cout<<"\n\n1. Add details\n";

cout<<"\n2. Display details\n\n3. User management\n";

Page 20: Cs investrigatory project

cout<<"\n4. Display passenger details\n\n5. Return to main menu\n";

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<<"\n\nDo you want to add one more record?\n";

cout<<"y-for Yes\nn-for No\n";

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)))

{

Page 21: Cs investrigatory project

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

{

Page 22: Cs investrigatory project

clrscr();

cout<<"1. Reserve\n\n2. Return to the main menu\n";

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)))

Page 23: Cs investrigatory project

{

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 PERSONNEL\n";

b.amc=b.nosr*((amt*50)/100);

}

else if(b.con==2)

{

cout<<"\nConcession category : SENIOR CITIZEN\n";

b.amc=b.nosr*((amt*60)/100);

}

else if(b.con==3)

{

Page 24: Cs investrigatory project

cout<<"\nConcession category : CHILDERN BELOW FIVE\n";

b.amc=0.0;

}

else if(b.con==4)

{

cout<<"\nYou cannot get any concession\n";

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)

{

Page 25: Cs investrigatory project

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 PRESONNEL\n";

b.amc=b.nosr*((amt*50)/100);

}

else if(b.con==2)

{

cout<<"\nConcession category : SENIOR CITIZEN\n";

b.amc=b.nosr*((amt*60)/100);

}

else if(b.con==3)

{

cout<<"\nConcession category : CHILDERN BELOW FIVE\n";

b.amc=0.0;

}

else if(b.con==4)

{

Page 26: Cs investrigatory project

cout<<"\nYou can not get any concession\n";

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;

}

}

Page 27: Cs investrigatory project

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();

Page 28: Cs investrigatory project

}

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";

Page 29: Cs investrigatory project

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;

Page 30: Cs investrigatory project

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;

Page 31: Cs investrigatory project

}

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)

{

Page 32: Cs investrigatory project

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

Page 33: Cs investrigatory project

{

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

{

Page 34: Cs investrigatory project

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<<"\n\n1. Cancel\n\n2. Return to the main menu\n";

cout<<"\nEnter your choice:";

Page 35: Cs investrigatory project

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<<"\n\nEnter your ID : "; gets(id);

Page 36: Cs investrigatory project

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<<"\n\n1. Reserve a ticket\n\n2. Cancel a ticket";

cout<<"\n\n3. Enquiry\n\n4. Return to the main menu\n";

cout<<"\nEnter your choice : ";

cin>>ch;

cout<<endl;

switch(ch)

{

case 1:

reserve();

break;

case 2:

cancell();

break;

case 3:

Page 37: Cs investrigatory project

enquiry();

break;

}

}while(ch<=3);

goto j;

}

else

{

d=1;

}

}

if(d==1)

{

cout<<"\nEnter user ID and password correctly\n";

}

getch();

j:

}

void manage()

{int ch;

fstream f;

char c;

login a;

clrscr();

Page 38: Cs investrigatory project

cout<<"---------------------------------------------------------\n";

cout<<" WELCOME TO THE USER MANAGEMENT MENU \n";

cout<<"---------------------------------------------------------\n";

do

{

cout<<"\n\n1. Add ID details of user \n";

cout<<"\n2. Display details of ID\n\n3. Return to the main menu\n";

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<<"\n\nDo you want to add one more record>?\n";

cout<<"y-Yes\nn-No\n";

cout<<"Your answer : ";

cin>>c;

}while(c=='y');

Page 39: Cs investrigatory project

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();

}

Page 40: Cs investrigatory project

Screen shots

Main menu

User mode

Page 41: Cs investrigatory project

User mode menu

Enquiry

Page 42: Cs investrigatory project

Reservation

Reservation status

Page 43: Cs investrigatory project

Cancellation

Cancellation status

Page 44: Cs investrigatory project

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.

Page 45: Cs investrigatory project

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