journey planner

69
Page 1 of 69

Upload: yashwant-r-kamath

Post on 25-Jan-2016

10 views

Category:

Documents


3 download

DESCRIPTION

journey planner

TRANSCRIPT

Page 1: journey planner

Page 1 of 69

Page 2: journey planner

Page 2 of 69

CERTIFICATE

This is hereby to certify that this original and given investigation about the

subject matter and related data collection and investigation has been completed

solely, sincerely and satisfactorily by

…………………………………………………… of class XII B, Bharatiya Vidya

Bhavan, Kodunganoor, regarding his project titled “Journey Planner”.

Teacher in-charge Principal

Examiner

Page 3: journey planner

Page 3 of 69

ACKNOWLEDGEMENT

At the outset, I thank the Almighty for standing by me throughout

my studies and helping me to complete the same.

I offer my sincere thanks to Mrs. Rekha .S, Head of Department

(Computer), Bharatiya Vidya Bhavan, Kodunganoor for the sincere

advice and continuous encouragement during the course of this work.

I gratefully acknowledge my parents, my friends and all my

teachers for their kind suggestions and co-operation during my work.

Finally, I wish to thank all those who helped me in one way or

another during the course of this project.

Page 4: journey planner

Page 4 of 69

CONTENTS

Sl no: PAGE NO:

1 Certificate 2

2 Acknowledgement 3

3 Introduction 5

4 Program Algorithm 7

5 Program Code 32

6 Output 56

7 Limitations 66

8 System Requirements 67

9 Bibliography 68

Page 5: journey planner

Page 5 of 69

Introduction The aim is to develop a C++ project to manage railway and

flight ticket reservation using Object Oriented Programming

(OOP) and data file handling.

The C++ programming language was developed at AT&T Bell

laboratories by Bjarne Stroustrup.He found “C” lacking in

realistic problem-solving and decided to extend the language.

The name C++ was coined by Rick Mascitti where”++”is the C

increment operator. Ever since its birth, C++ evolved to cope

with problems encountered by users, and through discussions

at AT&T. The major reasons for its success is the support for

OOP, which is most near to real world situations.

This is a project based on ticket reservation, and helps us to

enter, display or alter the details of different trains and flights,

in addition to the reservation and cancellation of tickets.It

includes various functions to do the above mentioned tasks.

DBMS:

DBMS is the software used to manage the data.Data file

handling has also been effectively used in the program.The

Page 6: journey planner

Page 6 of 69

database is a collection of interrelated data to serve multiple

applications, i.e database programs create files of information.

So we see that files are worked with most, inside the program.

Classes:

C++ provides us with the usage of classes. In OOP, a class is an

extensible program-code-template for creating objects,

providing initial values for member variables and implementing

the member functions.

Inheritance:

Inheritance allows one data type to acquire the properties of

other data types. The inheritance used in this program is

hierarchial inheritance -- a common base class for multiple

derived classes.

Page 7: journey planner

Page 7 of 69

Page 8: journey planner

Page 8 of 69

PROGRAM ALGORITHM

#include<iostream.h> #include<stdlib.h> #include<conio.h> #include<fstream.h> #include<stdio.h> #include<string.h> #include<dos.h> #include<process.h> Define a class basicinfo { int mon,tue,wed,thu,fri,sat,sun; float traveltime; public: char departure[25]; char destination[25]; basicinfo() { mon=0; tue=0; wed=0; thu=0; fri=0; sat=0; sun=0; traveltime=0; strcpy(destination,"\0"); strcpy(departure,"\0"); } void getbasic() { char daych; mon : print "\n\t\tWill there be trip on MONDAYS? (y/n) ?" ; daych=getch(); if (assign(mon,daych)==0) goto mon; tue : print "\n\t\tWill there be trip on TUESDAYS? (y/n) ?" ; daych=getch();

Page 9: journey planner

Page 9 of 69

if (assign(tue,daych)==0) goto tue; wed: print "\n\t\tWill there be trip on WEDNESDAYS? (y/n) ?" ; daych=getch(); if (assign(wed,daych)==0) goto wed; thu: print "\n\t\tWill there be trip on THURSDAYS? (y/n) ?" ; daych=getch(); if (assign(thu,daych)==0) goto thu; fri: print "\n\t\tWill there be trip on FRIDAYS? (y/n) ?" ; daych=getch(); if (assign(fri,daych)==0) goto fri; sat: print "\n\t\tWill there be trip on SATURDAYS? (y/n) ?" ; daych=getch(); if (assign(sat,daych)==0) goto sat; sun: print "\n\t\tWill there be trip on SUNDAYS? (y/n) ?" ; daych=getch(); if (assign(sun,daych)==0) goto sun; print "\n\t\tEnter travel time : "; read traveltime; print "\n\t\tEnter Departure City : "; gets(departure); strupr(departure); print "\n\t\tEnter Destination City : "; gets(destination); strupr(destination); } int assign(int&x,char y) { if(y=='y' || y=='Y') x=1; else if(y=='n' ||y=='N' ) x=0; else { print "\n\t\tInvalid choice. Please Enter again Correctly"; delay(1500); return(0); } }

Page 10: journey planner

Page 10 of 69

void showbasic() { int q=0; print "\n\t\tThere will be trips on : "; if(mon==1) { q++; print "\n\n\t\t" q ". Mondays "; } if(tue==1) { q++; print "\n\n\t\t" q ". Tuesdays "; } if(wed==1) { q++; print "\n\n\t\t" q ". Wednesdays "; } if(thu==1) { q++; print "\n\n\t\t" q ". Thursdays "; } if(fri==1) { q++; print "\n\n\t\t" q ". Fridays "; } if(sat==1) { q++; print "\n\n\t\t" q ". Saturdays "; } if(sun==1) { q++; print "\n\n\t\t" q ". Sundays "; } print "\n\n\n\n\t\tTime for travel : " traveltime; print "\n\n\n\t\tDeparture City : " departure; print "\n\n\n\t\tDestination City : " destination; } }; Define a class train derived from public basicinfo { long int trnno; char trnnm[25]; int tnoof1ac; int rnoof1ac;

Page 11: journey planner

Page 11 of 69

float cof1ac; float rcof1ac; int tnoof2ac; int rnoof2ac; float cof2ac; float rcof2ac; int tnoofslp; int rnoofslp; float cofslp; float rcofslp; public: train () { trnno=0; strcpy(trnnm,"\0"); tnoof1ac=0; rnoof1ac=0; cof1ac=0; rcof1ac=0; tnoof2ac=0; rnoof2ac=0; cof2ac=0; rcof2ac=0; tnoofslp=0; rnoofslp=0; cofslp=0; rcofslp=0; } void gettrain() { edit: print "\n\t\tEnter Train no."; read trnno; print "\n\t\tEnter train name : "; gets(trnnm); strupr(trnnm); print "\n\n\t\tFIRST CLASS A/C"; print "\n\t\t***************"; print "\n\n\t\t Enter the no. of First Class A/C seats : "; read tnoof1ac; print "\n\t\t Enter the charge of a First classA/C seat :"; read cof1ac; print "\n\t\t Enter the Reservation charge\n\t\t of a First class A/C seat :";

Page 12: journey planner

Page 12 of 69

read rcof1ac; print "\n\n\t\tSECOND CLASS A/C"; print "\n\t\t***************"; print "\n\n\t\t Enter the no. of Second Class A/C seats : "; read tnoof2ac; print "\n\t\t Enter the charge of a Second ClassA/C seat :"; read cof2ac; print "\n\t\t Enter the Reservation charge\n\t\t of a Second Class A/C seat :"; read rcof2ac; print "\n\n\t\tSLEEPER CLASS"; print "\n\t\t***************"; print "\n\n\t\t Enter the no. of Sleeper Class seats : "; read tnoofslp; print "\n\t\t Enter the charge of a Sleeper Class seat :"; read cofslp; print "\n\t\t Enter the Reservation charge\n\t\t of a Sleeper Class seat :"; read rcofslp; getbasic(); review : print "\n\t\tDo you want to review the details \n\t\tand then edit ? (y/n) ?"; char ch; ch=getch(); if(ch=='y'||ch=='Y') { clrscr(); showtrain(); editch : print "\n\t\tDo you want to Edit the details ? (y/n)?"; char ch1; ch1=getch(); if(ch1=='y'||ch1=='Y') goto edit; else if(ch1=='n'||ch1=='N') { clrscr(); print "\n\t\tEntry added"; success(); delay(2000); } else { fail(); print "\n\t\tPlease Enter a valid Input (y or n)"; delay(1500); goto editch; } } else if(ch=='n'||ch=='N')

Page 13: journey planner

Page 13 of 69

{ clrscr(); print "\n\t\tEntry added"; success(); delay(2000); } else { fail(); print "\n\t\tPlease Enter a valid Input (y or n)"; delay(1500); goto review; } } void showtrain() { print "\n\n\t\t" trnnm; print "\n\t\t*************"; print "\n\n\t\tTRAIN NO. : " trnno; print "\n\t\tTRAIN NAME : " trnnm; print "\n\n\t\tFIRST CLASS A/C"; print "\n\t\t****************"; print "\n\t\tNo. of First Class A/C seats : " tnoof1ac; print "\n\t\tNo. of Reserved First Class A/C seats : " rnoof1ac; print "\n\t\tRemaining No. of First Class A/C seats : " (tnoof1ac-rnoof1ac); print "\n\t\tCharge of a First Class A/C seat : " cof1ac; print "\n\t\tReservation Charge of a First Class A/C seat : " rcof1ac; print "\n\n\t\tSECOND CLASS A/C"; print "\n\t\t****************"; print "\n\t\tNo. of Second Class A/C seats : " tnoof2ac; print "\n\t\tNo. of Reserved Second Class A/C seats : " rnoof2ac; print "\n\t\tRemaining No. of Second Class A/C seats : " (tnoof2ac-rnoof2ac); print "\n\t\tCharge of a Second Class A/C seat : " cof2ac; print "\n\t\tReservation Charge of a Second Class A/C seat : " rcof2ac; print "\n\n\t\tSLEEPER CLASS"; print "\n\t\t****************"; print "\n\t\tNo. of Sleeper Class seats : " tnoofslp; print "\n\t\tNo. of Reserved Sleeper Class seats : " rnoofslp; print "\n\t\tRemaining No. of Sleeper Class seats : " (tnoofslp-rnoofslp); print "\n\t\tCharge of a Sleeper Class seat : " cofslp;

Page 14: journey planner

Page 14 of 69

print "\n\t\tReservation Charge of a Sleeper Class seat : " rcofslp; print "\n\t\t\t\t\t\t\t\tPage 1/2"; delay(3000); sound(600); delay(500); nosound(); print "\n\t\tPress any key to view next page"; getch(); clrscr(); showbasic(); } int rettrainno() { return (trnno); } int check(int x) { if(x==1) if((tnoof1ac-rnoof1ac-1)>=0) { rnoof1ac++; return(0);} else if(x==2) if((tnoof2ac-rnoof2ac-1)>=0) { rnoof2ac++; return(0);} else if(x==3) if((tnoofslp-rnoofslp-1)>=0) { rnoofslp++;return(0);} } }; Derive a class flight: public basicinfo { long int fltno; char fltnm[25]; int tnoofbc; int rnoofbc; float cofbc; float rcofbc; int tnoofec; int rnoofec; float cofec; float rcofec; char ftype[15];

Page 15: journey planner

Page 15 of 69

public: flight() { fltno=0; strcpy(fltnm,"\0"); tnoofbc=0; rnoofbc=0; cofbc=0; rcofbc=0; tnoofec=0; rnoofec=0; cofec=0; rcofec=0; strcpy(ftype,"\0"); } void getflight() { edit: print "\n\t\tEnter Flight no."; read fltno; print "\n\t\tEnter Flight Name : "; gets(fltnm); strupr(fltnm); print "\n\n\t\tBUSINESS CLASS "; print "\n\t\t***************"; print "\n\n\t\t Enter the no. of Business Class seats : "; read tnoofbc; print "\n\t\t Enter the charge of a Business class seat :"; read cofbc; print "\n\t\t Enter the Reservation charge\n\t\t of a Business class seat :"; read rcofbc; print "\n\n\t\tECONOMY CLASS A/C"; print "\n\t\t***************"; print "\n\n\t\t Enter the no. of Economy Class seats : "; read tnoofec; print "\n\t\t Enter the charge of a Economy Class seat :"; read cofec; print "\n\t\t Enter the Reservation charge\n\t\t of a Economy Class seat :"; read rcofec; getbasic(); review : print "\n\t\tDo you want to review the details \n\t\tand then edit ? (y/n) ?"; char ch; ch=getch(); if(ch=='y'||ch=='Y')

Page 16: journey planner

Page 16 of 69

{ clrscr(); showflight(); editch : print "\n\t\tDo you want to Edit the details ? (y/n)?"; char ch1; ch1=getch(); if(ch1=='y'||ch1=='Y') goto edit; else if(ch1=='n'||ch1=='N') { clrscr(); print "\n\t\tEntry added"; success(); delay(2000); } else { fail(); print "\n\t\tPlease Enter a valid Input (y or n)"; delay(1500); goto editch; } } else if(ch=='n'||ch=='N') { clrscr(); print "\n\t\tEntry added"; success(); delay(2000); } else { fail(); print "\n\t\tPlease Enter a valid Input (y or n)"; delay(1500); goto review; } } void showflight() { print "\n\n\t\t" fltnm; print "\n\t\t****************"; print "\n\n\t\tFLIGHT NO. : " fltno; print "\n\t\tFLIGHT NAME : " fltnm;

Page 17: journey planner

Page 17 of 69

print "\n\n\t\tBUSINESS CLASS A/C"; print "\n\t\t****************"; print "\n\t\tNo. of Business Class seats : " tnoofbc; print "\n\t\tNo. of Reserved Business Class seats : " rnoofbc; print "\n\t\tRemaining No. of Business Class seats : " (tnoofbc-rnoofbc); print "\n\t\tCharge of a Business Class seat : " cofbc; print "\n\t\tReservation Charge of a Business Class seat : " rcofbc; print "\n\n\t\tECONOMY CLASS "; print "\n\t\t****************"; print "\n\t\tNo. of Economy Class seats : " tnoofec; print "\n\t\tNo. of Reserved Economy Class seats : " rnoofec; print "\n\t\tRemaining No. of Economy Class seats : " (tnoofec-rnoofec); print "\n\t\tCharge of a Economy Class seat : " cofec; print "\n\t\tReservation Charge of a Economy Class seat : " rcofec; print "\n\t\t\t\t\t\t\t\tPage 1/2"; delay(3000); sound(600); delay(500); nosound(); print "\n\t\tPress any key to view next page"; getch(); clrscr(); showbasic(); } int retflightno() { return (fltno); } int check(int x) { if(x==1) { if((tnoofbc-rnoofbc-1)>=0) { rnoofbc++; return(0); } } else if(x==2) { if((tnoofec-rnoofec-1)>=0) { rnoofec++;

Page 18: journey planner

Page 18 of 69

return(0); } } } }; void success() { sound(400); delay(500); sound(500); delay(500); sound(600); delay(500); sound(700); delay(1000); nosound(); } void fail() { sound(600); delay(650); nosound(); delay(200); sound(600); delay(650); nosound(); delay(200); sound(600); delay(650); nosound(); delay(200); } void banner() { clrscr(); delay(250); gotoxy(1,15); print "\n\t\t\t||==============================||"; print "\n\t\t\t|| ||"; print "\n\t\t\t|| WELCOME TO JOURNEY PLANNER ||"; print "\n\t\t\t|| [WEEKLY BASIS] ||"; print "\n\t\t\t|| ||";

Page 19: journey planner

Page 19 of 69

print "\n\t\t\t||==============================||"; } void quit() { clrscr(); gotoxy(1,15); print "\n\t\t\t||===========================||"; print "\n\t\t\t|| ||"; print "\n\t\t\t|| THANK YOU FOR USING THE ||"; print "\n\t\t\t|| JOURNEY PLANNER ||"; print "\n\t\t\t|| ||"; print "\n\t\t\t||===========================||"; delay(2000); print "\n\t\t\t||===========================||"; print "\n\t\t\t|| ||"; print "\n\t\t\t|| PROJECT DEVELOPED BY ||"; print "\n\t\t\t|| ********************** ||"; print "\n\t\t\t|| ||"; print "\n\t\t\t|| => YASHWANT.R.KAMATH <= ||"; print "\n\t\t\t|| => YADU KRISHNAN <= ||"; print "\n\t\t\t|| => AMAL KRISHNA.R <= ||"; print "\n\t\t\t|| => R.GAUTHAM <= ||"; print "\n\t\t\t|| ^^^^^^^^^^^^^^^^^^^ ||"; print "\n\t\t\t||===========================||"; delay(3000); print "\n\n\t\t\tNOW EXITING...."; delay(2000); exit(0); } Derive a class ticket { int tickno,type,age,trno,stype; char name[50],destination[30],departure[30]; public : gettick() { gettick :clrscr(); gotoxy(1,15); print "\n\t\tSELECT\n\t\t1 . TRAIN\n\t\t2 . FLIGHT"; char tick; tick=getch();

Page 20: journey planner

Page 20 of 69

{ if(tick=='1') type=1; else if(tick=='2') type=2; else { print "\n\t\tENTER A VALID OPTION"; delay(1500); goto gettick; } } seatsel : clrscr(); gotoxy(1,15); if(type==1) { print "\n\t\t1 . 1ST CLASS A/C\n\t\t2 . 2ND CLASS A/C\n\t\t3 . SLEEPER CLASS"; char sch; sch=getch(); if(sch=='1') stype=1; else if(sch=='2') stype=2; else if(sch=='3') stype=3; else { print "\n\t\tPLEASE ENTER A VALID OPTION..."; delay(1500); goto seatsel; } clrscr(); gotoxy(1,15); print "\n\t\tENTER THE TRAIN NO."; read trno; } else if(type==2) { print "\n\t\t1 .BUSINESS CLASS \n\t\t2 . ECONOMY CLASS "; char sch; sch=getch(); if(sch=='1') stype=1; if(sch=='2')

Page 21: journey planner

Page 21 of 69

stype=2; else { print "\n\t\tPLEASE ENTER A VALID OPTION..."; delay(1500); goto seatsel; } clrscr(); gotoxy(1,15); print "\n\t\tENTER THE TRAIN/FLIGHT NO."; read trno; } } void getdettick() { clrscr(); gotoxy(1,15); print "ENTER NAME : "; gets(name); print "ENTER AGE : "; read age; } void showtick() { clrscr(); gotoxy(1,15); print "\n\t\tHERE'S YOUR TICKET....."; if(type==1) { print "\n\t\tTRAIN\n\t\t******"; print "\n\t\tTRAIN NO : " trno "\n\t\tSEAT TYPE : "; if(stype==1) print "1ST CLASS A/C"; if(stype==2) print "2ND CLASS A/C"; if(stype==3) print "SLEEPER CLASS "; } else if(type==2) { print "\n\t\tFLIGHT\n\t\t********"; print "\n\t\tFLIGHT NO : " trno "\n\t\tSEAT TYPE : "; if(stype==1) print "BUSINESS CLASS ";

Page 22: journey planner

Page 22 of 69

if(stype==2) print "ECONOMY CLASS "; } print "\n\t\tTICKET NO. : " tickno; print "\n\n\t\t NAME : " name "\n\t\tAGE : " age; print "\n\t\tFROM : " departure "\t\tTO : " destination; print "\n\t\t Press any key to continue"; getch(); } int rettype() { return (type); } int rettrno() { return (trno); } int returnstype() { return (stype); } void addtno(int x) { tickno=x; } void addpl(char dest[],char depart[]) { strcpy(destination,dest); strcpy(departure,depart); } int gettickno() {return(tickno); } } ; void book() { ticket t; t.gettick(); if (t.rettype()==1) { ifstream fin("train.dat",ios::binary); ofstream fout("train.dat",ios::binary); ofstream tin("ticket.dat",ios::app|ios::binary);

Page 23: journey planner

Page 23 of 69

int flag=0; fin.seekg(ios::end); if(fin.tellg()==-1) { print "\n\t\t FILE ERROR.. NOW EXITING..."; delay(1500); quit(); } fin.seekg(0); train tr; while(!fin.eof()) { long pos; pos= fin.tellg(); fin.read((char*)&tr,sizeof(tr)); if(t.rettrno()==tr.rettrainno()) { if(tr.check(t.returnstype())==0) { t.getdettick(); fout.seekp(pos); fout.write((char*)&tr,sizeof(tr)); randomize(); int k; k=random(5001)+1000; t.addtno(k); tin.write((char*)&t,sizeof(t)); t.addpl(tr.destination,tr.departure); t.showtick(); flag=1; fin.close(); fout.close(); tin.close(); break; } } } if(flag==0) print "\n\t\tNO SUCH TRAIN EXISTS... PLEASE CHECK AGAIN"; } if (t.rettype()==2)

Page 24: journey planner

Page 24 of 69

{ ifstream fin("flight.dat",ios::binary); ofstream fout("flight.dat",ios::app|ios::binary); ofstream tin("ticket.dat",ios::app|ios::binary); int flag=0; fin.seekg(ios::end); if(fin.tellg()==-1) { print "\n\t\t FILE ERROR.. NOW EXITING..."; delay(1500); quit(); } fin.seekg(0); while(!fin.eof()) { flight fl; long pos; pos= fin.tellg(); fin.read((char*)&fl,sizeof(fl)); if(t.rettrno()==fl.retflightno()) { if(fl.check(t.returnstype())==0) { t.getdettick(); fout.seekp(pos); fout.write((char*)&fl,sizeof(fl)); randomize(); int k; k=random(5001)+1000; t.addtno(k); tin.write((char*)&t,sizeof(t)); t.addpl(fl.destination,fl.departure); t.showtick(); flag=1; fin.close(); fout.close(); tin.close(); break; } } } if(flag==0) print "\n\t\tNO SUCH FLIGHT EXISTS... PLEASE CHECK AGAIN";

Page 25: journey planner

Page 25 of 69

} } void cancel() { ifstream fin ("ticket.dat",ios::binary); ofstream fout("temp.dat",ios::app,ios::binary); ticket t; int k; clrscr(); gotoxy(1,15); print "\n\t\tEnter the ticket no to be deleted"; read k; fin.seekg(ios::end); if(fin.tellg()==-1) { print "\n\t\t FILE ERROR.. NOW EXITING..."; delay(1500); quit(); } fin.seekg(0); while(!fin.eof()) { fin.read((char*)&t,sizeof(t)); if(t.gettickno()==k) { char ch; del : print "\n\t\tAre you sure u want to delete (y/n) ?"; ch=getch(); if(ch=='n'||ch=='N') fout.write((char*)&t,sizeof(t)); else if(ch=='y'||ch=='Y') { print "\n\t\tDELETED"; delay(1500); } else { print "\n\t\tPLEASE ENTER A VALID OPTION"; delay(1500); goto del; } } else fout.write((char*)&t,sizeof(t));

Page 26: journey planner

Page 26 of 69

remove("ticket.dat"); rename("temp.dat","ticket.dat"); } } void main() { clrscr(); for int bn=0;bn<4;bn++) { banner(); delay(250); } delay(1500); ws: clrscr(); gotoxy(1,15); print "\n\n\t\tWELCOME SCREEN"; print "\n\n\t\t***************"; print "\n\n\t\tYou must be logged in for any activity.."; print "\n\n\t\tLOGIN AS : "; print "\n\n\t\t1 . GUEST"; print "\n\n\t\t2 . ADMINISTRATOR"; print "\n\n\n\t\t3 . EXIT"; print "\n\n\n\t\tEnter your choice : "; char ch; ch=getch(); if(ch=='3') quit(); if(ch=='1') { user: clrscr(); gotoxy(1,15) ; print "\n\t\t1 . BOOK YOUR TICKET... "; print "\n\n\t\t2 . CANCEL YOUR TICKET... "; gotoxy(1,49); print " GO TO PREVIOUS MENU [G] \t\t\t\t\t\t[Q] QUIT"; ch=getch();

Page 27: journey planner

Page 27 of 69

if(ch=='1') book(); else if(ch=='2') cancel(); else if(ch=='g'||ch=='G') goto ws; else if(ch=='q'||ch=='Q') quit(); else { print "\n\t\tENTER A VALID OPTION"; delay(1500); goto user; } } if(ch=='2') { clrscr(); ifstream pi("password.dat",ios::binary); pi.seekg(ios::end); if(pi.tellg()==-1) { gotoxy(1,15); print "\n\t\tYOU HAVE NOT SET ANY PASSWORD YET.."; char *pn; pn=getpass("\n\t\tENTER NEW PASSWORD=>"); char pns[9]; strcpy(pns,pn); ofstream po("password.dat",ios::binary); po.write((char*)&pns,sizeof(pns)); } clrscr(); gotoxy(1,15); char *p; p=getpass("\n\t\t\tENTER THE ADMINISTRATOR PASSWORD!!!"); char pass[50],checkpass[50]; strcpy(pass,p); pi.seekg(0); pi.read((char*)&checkpass,sizeof(checkpass)); if(strcmp(pass,checkpass)!=0) {

Page 28: journey planner

Page 28 of 69

print "SORRY, WRONG PASSWORD"; delay(1500); goto ws; } if(strcmp(pass,checkpass)==0) { admin : clrscr(); gotoxy(1,15); print "\n\t\t1 . TRAIN"; print "\n\t\t2 . FLIGHT"; gotoxy(1,49); print " GO TO PREVIOUS MENU [G] \t\t\t\t\t\t[Q] QUIT"; ch=getch(); if(ch=='g'||ch=='G') goto ws; else if(ch=='q'||ch=='Q') quit(); else if(ch=='1') { admintr : clrscr(); gotoxy(1,15); print "\n\t\t1 . ADD TRAIN"; print "\n\t\t2 . VIEW ALL THE TRAINS"; print "\n\t\t3 . MODIFY A TRAIN"; print "\n\t\t4 . DELETE A TRAIN"; gotoxy(1,49); print " GO TO PREVIOUS MENU [G] \t\t\t\t\t\t[Q] QUIT"; ch=getch(); if(ch=='g'||ch=='G') goto admin; else if(ch=='q'||ch=='Q') quit(); else if(ch=='1') { clrscr(); train tr; tr.gettrain(); ofstream tout("train.dat",ios::app|ios::binary); tout.write((char*)&tr,sizeof(tr)); tout.close(); goto admin; } else if(ch=='2') {

Page 29: journey planner

Page 29 of 69

clrscr(); gotoxy(1,15); ifstream tin("train.dat",ios::binary); train t; tin.seekg(0); int q=0; while(!tin.eof()) { q++; tin.read((char*)&t,sizeof(t)); gotoxy(1,15); print "\n\t\tTRAIN NO. " q; t.showtrain(); getch(); clrscr(); } goto admintr; } else { clrscr(); gotoxy(1,15); print "\n\t\tENTER VALID OPTION"; delay(1500); goto admintr; } } else if(ch=='2') { adminfl : clrscr(); gotoxy(1,15); print "\n\t\t1 . ADD FLIGHT"; print "\n\t\t2 . VIEW ALL THE FLIGHTS"; print "\n\t\t3 . MODIFY A FLIGHT"; print "\n\t\t4 . DELETE A FLIGHT"; gotoxy(1,49); print " GO TO PREVIOUS MENU [G] \t\t\t\t\t\t[Q] QUIT"; ch=getch(); if(ch=='g'||ch=='G') goto admin;

Page 30: journey planner

Page 30 of 69

else if(ch=='q'||ch=='Q') quit(); else if(ch=='1') { clrscr(); flight fl; fl.getflight(); ofstream tout("flight.dat",ios::app|ios::binary); tout.write((char*)&fl,sizeof(fl)); tout.close(); goto admin; } else if(ch=='2') { clrscr(); gotoxy(1,15); ifstream tin("flight.dat",ios::binary); flight f; tin.seekg(0); int q=0; while(!tin.eof()) { q++; tin.read((char*)&f,sizeof(f)); gotoxy(1,15); print "\n\t\tFLIGHT NO. " q; f.showflight(); getch(); clrscr(); } goto adminfl; } else { clrscr(); gotoxy(1,15); print "\n\t\tENTER VALID OPTION"; delay(1500); goto adminfl; } }

Page 31: journey planner

Page 31 of 69

} } else { print "\n\t\tENTER A VALID OPTION..."; delay(1500); goto ws; } getch(); }

Page 32: journey planner

Page 32 of 69

Page 33: journey planner

Page 33 of 69

PROGRAM CODE

#include<iostream.h>

#include<stdlib.h>

#include<conio.h>

#include<fstream.h>

#include<stdio.h>

#include<string.h>

#include<dos.h>

#include<process.h>

class basicinfo

{

int mon,tue,wed,thu,fri,sat,sun;

float traveltime;

public:

char departure[25];

char destination[25];

basicinfo()

{

mon=0;

tue=0;

wed=0;

thu=0;

fri=0;

sat=0;

sun=0;

traveltime=0;

strcpy(destination,"\0");

strcpy(departure,"\0");

}

void getbasic()

{ char daych;

mon : cout<<"\n\t\tWill there be trip on MONDAYS? (y/n) ?" ;

daych=getch();

if (assign(mon,daych)==0)

goto mon;

tue : cout<<"\n\t\tWill there be trip on TUESDAYS? (y/n) ?"

;

Page 34: journey planner

Page 34 of 69

daych=getch();

if (assign(tue,daych)==0)

goto tue;

wed: cout<<"\n\t\tWill there be trip on WEDNESDAYS? (y/n)

?" ;

daych=getch();

if (assign(wed,daych)==0)

goto wed;

thu: cout<<"\n\t\tWill there be trip on THURSDAYS? (y/n) ?"

;

daych=getch();

if (assign(thu,daych)==0)

goto thu;

fri: cout<<"\n\t\tWill there be trip on FRIDAYS? (y/n) ?" ;

daych=getch();

if (assign(fri,daych)==0)

goto fri;

sat: cout<<"\n\t\tWill there be trip on SATURDAYS? (y/n) ?"

;

daych=getch();

if (assign(sat,daych)==0)

goto sat;

sun: cout<<"\n\t\tWill there be trip on SUNDAYS? (y/n) ?" ;

daych=getch();

if (assign(sun,daych)==0)

goto sun;

cout<<"\n\t\tEnter travel time : ";

cin>>traveltime;

cout<<"\n\t\tEnter Departure City : ";

gets(departure);

strupr(departure);

cout<<"\n\t\tEnter Destination City : ";

gets(destination);

strupr(destination);

}

int assign(int&x,char y)

{

if(y=='y' || y=='Y')

x=1;

else if(y=='n' ||y=='N' )

x=0;

else

{ cout<<"\n\t\tInvalid choice. Please Enter again

Correctly";

delay(1500);

return(0);

}

Page 35: journey planner

Page 35 of 69

}

void showbasic()

{ int q=0;

cout<<"\n\t\tThere will be trips on : ";

if(mon==1)

{ q++;

cout<<"\n\n\t\t"<<q<<". Mondays ";

}

if(tue==1)

{ q++;

cout<<"\n\n\t\t"<<q<<". Tuesdays ";

}

if(wed==1)

{ q++;

cout<<"\n\n\t\t"<<q<<". Wednesdays ";

}

if(thu==1)

{ q++;

cout<<"\n\n\t\t"<<q<<". Thursdays ";

}

if(fri==1)

{ q++;

cout<<"\n\n\t\t"<<q<<". Fridays ";

}

if(sat==1)

{ q++;

cout<<"\n\n\t\t"<<q<<". Saturdays ";

}

if(sun==1)

{ q++;

cout<<"\n\n\t\t"<<q<<". Sundays ";

}

cout<<"\n\n\n\n\t\tTime for travel : "<<traveltime;

cout<<"\n\n\n\t\tDeparture City : "<<departure;

cout<<"\n\n\n\t\tDestination City : "<<destination;

}

};

class train : public basicinfo

{

long int trnno;

char trnnm[25];

int tnoof1ac;

int rnoof1ac;

float cof1ac;

Page 36: journey planner

Page 36 of 69

float rcof1ac;

int tnoof2ac;

int rnoof2ac;

float cof2ac;

float rcof2ac;

int tnoofslp;

int rnoofslp;

float cofslp;

float rcofslp;

public:

train ()

{ trnno=0;

strcpy(trnnm,"\0");

tnoof1ac=0;

rnoof1ac=0;

cof1ac=0;

rcof1ac=0;

tnoof2ac=0;

rnoof2ac=0;

cof2ac=0;

rcof2ac=0;

tnoofslp=0;

rnoofslp=0;

cofslp=0;

rcofslp=0;

}

void gettrain()

{

edit: cout<<"\n\t\tEnter Train no.";

cin>>trnno;

cout<<"\n\t\tEnter train name : ";

gets(trnnm);

strupr(trnnm);

cout<<"\n\n\t\tFIRST CLASS A/C";

cout<<"\n\t\t***************";

cout<<"\n\n\t\t Enter the no. of First Class A/C seats :

";

cin>>tnoof1ac;

cout<<"\n\t\t Enter the charge of a First classA/C seat

:";

cin>>cof1ac;

cout<<"\n\t\t Enter the Reservation charge\n\t\t of a

First class A/C seat :";

cin>>rcof1ac;

Page 37: journey planner

Page 37 of 69

cout<<"\n\n\t\tSECOND CLASS A/C";

cout<<"\n\t\t***************";

cout<<"\n\n\t\t Enter the no. of Second Class A/C seats

: ";

cin>>tnoof2ac;

cout<<"\n\t\t Enter the charge of a Second ClassA/C seat

:";

cin>>cof2ac;

cout<<"\n\t\t Enter the Reservation charge\n\t\t of a

Second Class A/C seat :";

cin>>rcof2ac;

cout<<"\n\n\t\tSLEEPER CLASS";

cout<<"\n\t\t***************";

cout<<"\n\n\t\t Enter the no. of Sleeper Class seats :

";

cin>>tnoofslp;

cout<<"\n\t\t Enter the charge of a Sleeper Class seat

:";

cin>>cofslp;

cout<<"\n\t\t Enter the Reservation charge\n\t\t of a

Sleeper Class seat :";

cin>>rcofslp;

getbasic();

review : cout<<"\n\t\tDo you want to review the details

\n\t\tand then edit ? (y/n) ?";

char ch;

ch=getch();

if(ch=='y'||ch=='Y')

{ clrscr();

showtrain();

editch : cout<<"\n\t\tDo you want to Edit the details ?

(y/n)?";

char ch1;

ch1=getch();

if(ch1=='y'||ch1=='Y')

goto edit;

else if(ch1=='n'||ch1=='N')

{ clrscr();

cout<<"\n\t\tEntry added";

success();

delay(2000);

}

else

{ fail();

cout<<"\n\t\tPlease Enter a valid Input (y or

n)";

Page 38: journey planner

Page 38 of 69

delay(1500);

goto editch;

}

}

else if(ch=='n'||ch=='N')

{

clrscr();

cout<<"\n\t\tEntry added";

success();

delay(2000);

}

else

{ fail();

cout<<"\n\t\tPlease Enter a valid Input (y or

n)";

delay(1500);

goto review;

}

}

void showtrain()

{

cout<<"\n\n\t\t"<<trnnm;

cout<<"\n\t\t*************";

cout<<"\n\n\t\tTRAIN NO. : "<<trnno;

cout<<"\n\t\tTRAIN NAME : "<<trnnm;

cout<<"\n\n\t\tFIRST CLASS A/C";

cout<<"\n\t\t****************";

cout<<"\n\t\tNo. of First Class A/C seats : "<<tnoof1ac;

cout<<"\n\t\tNo. of Reserved First Class A/C seats :

"<<rnoof1ac;

cout<<"\n\t\tRemaining No. of First Class A/C seats :

"<<(tnoof1ac-rnoof1ac);

cout<<"\n\t\tCharge of a First Class A/C seat :

"<<cof1ac;

cout<<"\n\t\tReservation Charge of a First Class A/C

seat : "<<rcof1ac;

cout<<"\n\n\t\tSECOND CLASS A/C";

cout<<"\n\t\t****************";

cout<<"\n\t\tNo. of Second Class A/C seats :

"<<tnoof2ac;

cout<<"\n\t\tNo. of Reserved Second Class A/C seats :

"<<rnoof2ac;

Page 39: journey planner

Page 39 of 69

cout<<"\n\t\tRemaining No. of Second Class A/C seats :

"<<(tnoof2ac-rnoof2ac);

cout<<"\n\t\tCharge of a Second Class A/C seat :

"<<cof2ac;

cout<<"\n\t\tReservation Charge of a Second Class A/C

seat : "<<rcof2ac;

cout<<"\n\n\t\tSLEEPER CLASS";

cout<<"\n\t\t****************";

cout<<"\n\t\tNo. of Sleeper Class seats : "<<tnoofslp;

cout<<"\n\t\tNo. of Reserved Sleeper Class seats :

"<<rnoofslp;

cout<<"\n\t\tRemaining No. of Sleeper Class seats :

"<<(tnoofslp-rnoofslp);

cout<<"\n\t\tCharge of a Sleeper Class seat : "<<cofslp;

cout<<"\n\t\tReservation Charge of a Sleeper Class seat

: "<<rcofslp;

cout<<"\n\t\t\t\t\t\t\t\tPage 1/2";

delay(3000);

sound(600);

delay(500);

nosound();

cout<<"\n\t\tPress any key to view next page";

getch();

clrscr();

showbasic();

}

int rettrainno()

{

return (trnno);

}

int check(int x)

{

if(x==1)

if((tnoof1ac-rnoof1ac-1)>=0)

{ rnoof1ac++; return(0);}

else if(x==2)

if((tnoof2ac-rnoof2ac-1)>=0)

{ rnoof2ac++; return(0);}

else if(x==3)

if((tnoofslp-rnoofslp-1)>=0)

{ rnoofslp++;return(0);}

}

};

Page 40: journey planner

Page 40 of 69

class flight: public basicinfo

{

long int fltno;

char fltnm[25];

int tnoofbc;

int rnoofbc;

float cofbc;

float rcofbc;

int tnoofec;

int rnoofec;

float cofec;

float rcofec;

char ftype[15];

public:

flight()

{ fltno=0;

strcpy(fltnm,"\0");

tnoofbc=0;

rnoofbc=0;

cofbc=0;

rcofbc=0;

tnoofec=0;

rnoofec=0;

cofec=0;

rcofec=0;

strcpy(ftype,"\0");

}

void getflight()

{

edit: cout<<"\n\t\tEnter Flight no.";

cin>>fltno;

cout<<"\n\t\tEnter Flight Name : ";

gets(fltnm);

strupr(fltnm);

cout<<"\n\n\t\tBUSINESS CLASS ";

cout<<"\n\t\t***************";

cout<<"\n\n\t\t Enter the no. of Business Class seats :

";

cin>>tnoofbc;

cout<<"\n\t\t Enter the charge of a Business class seat

:";

cin>>cofbc;

cout<<"\n\t\t Enter the Reservation charge\n\t\t of a

Business class seat :";

cin>>rcofbc;

Page 41: journey planner

Page 41 of 69

cout<<"\n\n\t\tECONOMY CLASS A/C";

cout<<"\n\t\t***************";

cout<<"\n\n\t\t Enter the no. of Economy Class seats :

";

cin>>tnoofec;

cout<<"\n\t\t Enter the charge of a Economy Class seat

:";

cin>>cofec;

cout<<"\n\t\t Enter the Reservation charge\n\t\t of a

Economy Class seat :";

cin>>rcofec;

getbasic();

review : cout<<"\n\t\tDo you want to review the details

\n\t\tand then edit ? (y/n) ?";

char ch;

ch=getch();

if(ch=='y'||ch=='Y')

{ clrscr();

showflight();

editch : cout<<"\n\t\tDo you want to Edit the details ?

(y/n)?";

char ch1;

ch1=getch();

if(ch1=='y'||ch1=='Y')

goto edit;

else if(ch1=='n'||ch1=='N')

{ clrscr();

cout<<"\n\t\tEntry added";

success();

delay(2000);

}

else

{ fail();

cout<<"\n\t\tPlease Enter a valid Input (y or

n)";

delay(1500);

goto editch;

}

}

else if(ch=='n'||ch=='N')

{

clrscr();

cout<<"\n\t\tEntry added";

success();

delay(2000);

}

Page 42: journey planner

Page 42 of 69

else

{ fail();

cout<<"\n\t\tPlease Enter a valid Input (y or

n)";

delay(1500);

goto review;

}

}

void showflight()

{

cout<<"\n\n\t\t"<<fltnm;

cout<<"\n\t\t****************";

cout<<"\n\n\t\tFLIGHT NO. : "<<fltno;

cout<<"\n\t\tFLIGHT NAME : "<<fltnm;

cout<<"\n\n\t\tBUSINESS CLASS A/C";

cout<<"\n\t\t****************";

cout<<"\n\t\tNo. of Business Class seats : "<<tnoofbc;

cout<<"\n\t\tNo. of Reserved Business Class seats :

"<<rnoofbc;

cout<<"\n\t\tRemaining No. of Business Class seats :

"<<(tnoofbc-rnoofbc);

cout<<"\n\t\tCharge of a Business Class seat : "<<cofbc;

cout<<"\n\t\tReservation Charge of a Business Class seat

: "<<rcofbc;

cout<<"\n\n\t\tECONOMY CLASS ";

cout<<"\n\t\t****************";

cout<<"\n\t\tNo. of Economy Class seats : "<<tnoofec;

cout<<"\n\t\tNo. of Reserved Economy Class seats :

"<<rnoofec;

cout<<"\n\t\tRemaining No. of Economy Class seats :

"<<(tnoofec-rnoofec);

cout<<"\n\t\tCharge of a Economy Class seat : "<<cofec;

cout<<"\n\t\tReservation Charge of a Economy Class seat

: "<<rcofec;

cout<<"\n\t\t\t\t\t\t\t\tPage 1/2";

delay(3000);

sound(600);

delay(500);

nosound();

cout<<"\n\t\tPress any key to view next page";

getch();

clrscr();

Page 43: journey planner

Page 43 of 69

showbasic();

}

int retflightno()

{

return (fltno);

}

int check(int x)

{

if(x==1)

{

if((tnoofbc-rnoofbc-1)>=0)

{ rnoofbc++;

return(0);

}

}

else if(x==2)

{ if((tnoofec-rnoofec-1)>=0)

{

rnoofec++;

return(0);

}

}

}

};

void success()

{

sound(400);

delay(500);

sound(500);

delay(500);

sound(600);

delay(500);

sound(700);

delay(1000);

nosound();

}

void fail()

{

sound(600);

delay(650);

nosound();

delay(200);

sound(600);

delay(650);

Page 44: journey planner

Page 44 of 69

nosound();

delay(200);

sound(600);

delay(650);

nosound();

delay(200);

}

void banner()

{ clrscr();

delay(250);

gotoxy(1,15);

cout<<"\n\t\t\t||==============================||";

cout<<"\n\t\t\t|| ||";

cout<<"\n\t\t\t|| WELCOME TO JOURNEY PLANNER ||";

cout<<"\n\t\t\t|| [WEEKLY BASIS] ||";

cout<<"\n\t\t\t|| ||";

cout<<"\n\t\t\t||==============================||";

}

void quit()

{

clrscr();

gotoxy(1,15);

cout<<"\n\t\t\t||===========================||";

cout<<"\n\t\t\t|| ||";

cout<<"\n\t\t\t|| THANK YOU FOR USING THE ||";

cout<<"\n\t\t\t|| JOURNEY PLANNER ||";

cout<<"\n\t\t\t|| ||";

cout<<"\n\t\t\t||===========================||";

delay(2000);

cout<<"\n\t\t\t||===========================||";

cout<<"\n\t\t\t|| ||";

cout<<"\n\t\t\t|| PROJECT DEVELOPED BY ||";

cout<<"\n\t\t\t|| ********************** ||";

cout<<"\n\t\t\t|| ||";

cout<<"\n\t\t\t|| => YASHWANT.R.KAMATH <= ||";

cout<<"\n\t\t\t|| => YADU KRISHNAN <= ||";

cout<<"\n\t\t\t|| => AMAL KRISHNA.R <= ||";

cout<<"\n\t\t\t|| => R.GAUTHAM <= ||";

cout<<"\n\t\t\t|| ^^^^^^^^^^^^^^^^^^^ ||";

cout<<"\n\t\t\t||===========================||";

delay(3000);

cout<<"\n\n\t\t\tNOW EXITING....";

delay(2000);

exit(0);

Page 45: journey planner

Page 45 of 69

}

class ticket

{

int tickno,type,age,trno,stype;

char name[50],destination[30],departure[30];

public :

gettick()

{

gettick :clrscr();

gotoxy(1,15);

cout<<"\n\t\tSELECT\n\t\t1 . TRAIN\n\t\t2 . FLIGHT";

char tick;

tick=getch();

{

if(tick=='1')

type=1;

else if(tick=='2')

type=2;

else

{ cout<<"\n\t\tENTER A VALID OPTION";

delay(1500);

goto gettick;

}

}

seatsel : clrscr();

gotoxy(1,15);

if(type==1)

{

cout<<"\n\t\t1 . 1ST CLASS A/C\n\t\t2 . 2ND CLASS

A/C\n\t\t3 . SLEEPER CLASS";

char sch;

sch=getch();

if(sch=='1')

stype=1;

else if(sch=='2')

stype=2;

else if(sch=='3')

stype=3;

else

{

cout<<"\n\t\tPLEASE ENTER A VALID OPTION...";

delay(1500);

goto seatsel;

}

clrscr();

Page 46: journey planner

Page 46 of 69

gotoxy(1,15);

cout<<"\n\t\tENTER THE TRAIN NO.";

cin>>trno;

}

else if(type==2)

{

cout<<"\n\t\t1 .BUSINESS CLASS \n\t\t2 . ECONOMY CLASS

";

char sch;

sch=getch();

if(sch=='1')

stype=1;

if(sch=='2')

stype=2;

else

{

cout<<"\n\t\tPLEASE ENTER A VALID OPTION...";

delay(1500);

goto seatsel;

}

clrscr();

gotoxy(1,15);

cout<<"\n\t\tENTER THE TRAIN/FLIGHT NO.";

cin>>trno;

}

}

void getdettick()

{

clrscr();

gotoxy(1,15);

cout<<"ENTER NAME : ";

gets(name);

cout<<"ENTER AGE : ";

cin>>age;

}

void showtick()

{

clrscr();

gotoxy(1,15);

cout<<"\n\t\tHERE'S YOUR TICKET.....";

if(type==1)

{

cout<<"\n\t\tTRAIN\n\t\t******";

cout<<"\n\t\tTRAIN NO : "<<trno<<"\n\t\tSEAT TYPE : ";

if(stype==1)

cout<<"1ST CLASS A/C";

if(stype==2)

Page 47: journey planner

Page 47 of 69

cout<<"2ND CLASS A/C";

if(stype==3)

cout<<"SLEEPER CLASS ";

}

else if(type==2)

{

cout<<"\n\t\tFLIGHT\n\t\t********";

cout<<"\n\t\tFLIGHT NO : "<<trno<<"\n\t\tSEAT TYPE : ";

if(stype==1)

cout<<"BUSINESS CLASS ";

if(stype==2)

cout<<"ECONOMY CLASS ";

}

cout<<"\n\t\tTICKET NO. : "<<tickno;

cout<<"\n\n\t\t NAME : "<<name<<"\n\t\tAGE : "<<age;

cout<<"\n\t\tFROM : "<<departure<<"\t\tTO :

"<<destination;

cout<<"\n\t\t Press any key to continue";

getch();

}

int rettype()

{

return (type);

}

int rettrno()

{

return (trno);

}

int returnstype()

{

return (stype);

}

void addtno(int x)

{

tickno=x;

}

void addpl(char dest[],char depart[])

{

strcpy(destination,dest);

strcpy(departure,depart);

}

int gettickno()

{return(tickno);

}

} ;

void book()

Page 48: journey planner

Page 48 of 69

{

ticket t;

t.gettick();

if (t.rettype()==1)

{

ifstream fin("train.dat",ios::binary);

ofstream fout("train.dat",ios::binary);

ofstream tin("ticket.dat",ios::app|ios::binary);

int flag=0;

fin.seekg(ios::end);

if(fin.tellg()==-1)

{

cout<<"\n\t\t FILE ERROR.. NOW EXITING...";

delay(1500);

quit();

}

fin.seekg(0);

train tr;

while(!fin.eof())

{

long pos;

pos= fin.tellg();

fin.read((char*)&tr,sizeof(tr));

if(t.rettrno()==tr.rettrainno())

{

if(tr.check(t.returnstype())==0)

{

t.getdettick();

fout.seekp(pos);

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

randomize();

int k;

k=random(5001)+1000;

t.addtno(k);

tin.write((char*)&t,sizeof(t));

t.addpl(tr.destination,tr.departure);

t.showtick();

flag=1;

fin.close();

fout.close();

tin.close();

break;

}

}

}

Page 49: journey planner

Page 49 of 69

if(flag==0)

cout<<"\n\t\tNO SUCH TRAIN EXISTS... PLEASE CHECK

AGAIN";

}

if (t.rettype()==2)

{

ifstream fin("flight.dat",ios::binary);

ofstream fout("flight.dat",ios::app|ios::binary);

ofstream tin("ticket.dat",ios::app|ios::binary);

int flag=0;

fin.seekg(ios::end);

if(fin.tellg()==-1)

{

cout<<"\n\t\t FILE ERROR.. NOW EXITING...";

delay(1500);

quit();

}

fin.seekg(0);

while(!fin.eof())

{

flight fl;

long pos;

pos= fin.tellg();

fin.read((char*)&fl,sizeof(fl));

if(t.rettrno()==fl.retflightno())

{

if(fl.check(t.returnstype())==0)

{

t.getdettick();

fout.seekp(pos);

fout.write((char*)&fl,sizeof(fl));

randomize();

int k;

k=random(5001)+1000;

t.addtno(k);

tin.write((char*)&t,sizeof(t));

t.addpl(fl.destination,fl.departure);

t.showtick();

flag=1;

fin.close();

fout.close();

tin.close();

break;

}

}

Page 50: journey planner

Page 50 of 69

}

if(flag==0)

cout<<"\n\t\tNO SUCH FLIGHT EXISTS... PLEASE CHECK

AGAIN";

}

}

void cancel()

{

ifstream fin ("ticket.dat",ios::binary);

ofstream fout("temp.dat",ios::app,ios::binary);

ticket t;

int k;

clrscr();

gotoxy(1,15);

cout<<"\n\t\tEnter the ticket no to be deleted";

cin>>k;

fin.seekg(ios::end);

if(fin.tellg()==-1)

{

cout<<"\n\t\t FILE ERROR.. NOW EXITING...";

delay(1500);

quit();

}

fin.seekg(0);

while(!fin.eof())

{

fin.read((char*)&t,sizeof(t));

if(t.gettickno()==k)

{ char ch;

del : cout<<"\n\t\tAre you sure u want to delete

(y/n) ?";

ch=getch();

if(ch=='n'||ch=='N')

fout.write((char*)&t,sizeof(t));

else if(ch=='y'||ch=='Y')

{

cout<<"\n\t\tDELETED";

delay(1500);

}

else

{

cout<<"\n\t\tPLEASE ENTER A VALID OPTION";

delay(1500);

goto del;

}

}

Page 51: journey planner

Page 51 of 69

else

fout.write((char*)&t,sizeof(t));

remove("ticket.dat");

rename("temp.dat","ticket.dat");

}

}

void main()

{

clrscr();

for(int bn=0;bn<4;bn++)

{ banner();

delay(250);

}

delay(1500);

ws: clrscr();

gotoxy(1,15);

cout<<"\n\n\t\tWELCOME SCREEN";

cout<<"\n\n\t\t***************";

cout<<"\n\n\t\tYou must be logged in for any activity..";

cout<<"\n\n\t\tLOGIN AS : ";

cout<<"\n\n\t\t1 . GUEST";

cout<<"\n\n\t\t2 . ADMINISTRATOR";

cout<<"\n\n\n\t\t3 . EXIT";

cout<<"\n\n\n\t\tEnter your choice : ";

char ch;

ch=getch();

if(ch=='3')

quit();

if(ch=='1')

{

user:

clrscr();

gotoxy(1,15) ;

cout<<"\n\t\t1 . BOOK YOUR TICKET... ";

cout<<"\n\n\t\t2 . CANCEL YOUR TICKET... ";

gotoxy(1,49);

cout<<"<<GO TO PREVIOUS MENU [G] \t\t\t\t\t\t[Q] QUIT";

ch=getch();

if(ch=='1')

Page 52: journey planner

Page 52 of 69

book();

else if(ch=='2')

cancel();

else if(ch=='g'||ch=='G')

goto ws;

else if(ch=='q'||ch=='Q')

quit();

else

{

cout<<"\n\t\tENTER A VALID OPTION";

delay(1500);

goto user;

}

}

if(ch=='2')

{

clrscr();

ifstream pi("password.dat",ios::binary);

pi.seekg(ios::end);

if(pi.tellg()==-1)

{

gotoxy(1,15);

cout<<"\n\t\tYOU HAVE NOT SET ANY PASSWORD YET..";

char *pn;

pn=getpass("\n\t\tENTER NEW PASSWORD=>");

char pns[9];

strcpy(pns,pn);

ofstream po("password.dat",ios::binary);

po.write((char*)&pns,sizeof(pns));

}

clrscr();

gotoxy(1,15);

char *p;

p=getpass("\n\t\t\tENTER THE ADMINISTRATOR

PASSWORD!!!");

char pass[50],checkpass[50];

strcpy(pass,p);

pi.seekg(0);

pi.read((char*)&checkpass,sizeof(checkpass));

if(strcmp(pass,checkpass)!=0)

{

cout<<"SORRY, WRONG PASSWORD";

delay(1500);

goto ws;

Page 53: journey planner

Page 53 of 69

}

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

{

admin : clrscr();

gotoxy(1,15);

cout<<"\n\t\t1 . TRAIN";

cout<<"\n\t\t2 . FLIGHT";

gotoxy(1,49);

cout<<"<<GO TO PREVIOUS MENU [G] \t\t\t\t\t\t[Q]

QUIT";

ch=getch();

if(ch=='g'||ch=='G')

goto ws;

else if(ch=='q'||ch=='Q')

quit();

else if(ch=='1')

{

admintr : clrscr();

gotoxy(1,15);

cout<<"\n\t\t1 . ADD TRAIN";

cout<<"\n\t\t2 . VIEW ALL THE TRAINS";

cout<<"\n\t\t3 . MODIFY A TRAIN";

cout<<"\n\t\t4 . DELETE A TRAIN";

gotoxy(1,49);

cout<<"<<GO TO PREVIOUS MENU [G] \t\t\t\t\t\t[Q]

QUIT";

ch=getch();

if(ch=='g'||ch=='G')

goto admin;

else if(ch=='q'||ch=='Q')

quit();

else if(ch=='1')

{

clrscr();

train tr;

tr.gettrain();

ofstream

tout("train.dat",ios::app|ios::binary);

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

tout.close();

goto admin;

}

else if(ch=='2')

{

clrscr();

gotoxy(1,15);

ifstream tin("train.dat",ios::binary);

Page 54: journey planner

Page 54 of 69

train t;

tin.seekg(0);

int q=0;

while(!tin.eof())

{ q++;

tin.read((char*)&t,sizeof(t));

gotoxy(1,15);

cout<<"\n\t\tTRAIN NO. "<<q;

t.showtrain();

getch();

clrscr();

}

goto admintr;

}

else

{

clrscr();

gotoxy(1,15);

cout<<"\n\t\tENTER VALID OPTION";

delay(1500);

goto admintr;

}

}

else if(ch=='2')

{

adminfl : clrscr();

gotoxy(1,15);

cout<<"\n\t\t1 . ADD FLIGHT";

cout<<"\n\t\t2 . VIEW ALL THE FLIGHTS";

cout<<"\n\t\t3 . MODIFY A FLIGHT";

cout<<"\n\t\t4 . DELETE A FLIGHT";

gotoxy(1,49);

cout<<"<<GO TO PREVIOUS MENU [G] \t\t\t\t\t\t[Q]

QUIT";

ch=getch();

if(ch=='g'||ch=='G')

goto admin;

else if(ch=='q'||ch=='Q')

quit();

else if(ch=='1')

{

clrscr();

Page 55: journey planner

Page 55 of 69

flight fl;

fl.getflight();

ofstream

tout("flight.dat",ios::app|ios::binary);

tout.write((char*)&fl,sizeof(fl));

tout.close();

goto admin;

}

else if(ch=='2')

{

clrscr();

gotoxy(1,15);

ifstream tin("flight.dat",ios::binary);

flight f;

tin.seekg(0);

int q=0;

while(!tin.eof())

{ q++;

tin.read((char*)&f,sizeof(f));

gotoxy(1,15);

cout<<"\n\t\tFLIGHT NO. "<<q;

f.showflight();

getch();

clrscr();

}

goto adminfl;

}

else

{

clrscr();

gotoxy(1,15);

cout<<"\n\t\tENTER VALID OPTION";

delay(1500);

goto adminfl;

}

}

}

}

Page 56: journey planner

Page 56 of 69

else

{ cout<<"\n\t\tENTER A VALID OPTION...";

delay(1500);

goto ws;

}

getch();

}

Page 57: journey planner

Page 57 of 69

Page 58: journey planner

Page 58 of 69

PROGRAM OUTPUT

SCREEN 1: FRONT BANNER

||==============================|| || || || WELCOME TO JOURNEY PLANNER || || [WEEKLY BASIS] || || || ||==============================||

SCREEN 2: WELCOME SCREEN WELCOME SCREEN *************** You must be logged in for any activity… LOGIN AS : 1 . GUEST 2 . ADMINISTRATOR 3 . EXIT Enter your choice

INPUT : “2”

Page 59: journey planner

Page 59 of 69

SCREEN 3: ADMINISTRATOR LOGIN ENTER THE ADMINISTRATOR PASSWORD!!!

INPUT : (SET PASSWORD)

SCREEN 4: ADMINISTRATOR MENU 1 . TRAIN 2 . FLIGHT 3 . CHANGE PASSWORD <<GO TO PREVIOUS MENU [G] [Q] QUIT

INPUT : “1”

Page 60: journey planner

Page 60 of 69

SCREEN 5 : ADMIN’S TRAIN MENU

1 . ADD TRAIN 2 . VIEW ALL THE TRAINS 3 . MODIFY A TRAIN 4 . DELETE A TRAIN <<GO TO PREVIOUS MENU [G] [Q] QUIT

INPUT : “1”

Page 61: journey planner

Page 61 of 69

SCREEN 5: TRAIN DETAILS INPUT

Enter Train no.1234 Enter train name : RAJADHANI FIRST CLASS A/C *************** Enter the no. of First Class A/C seats : 5 Enter the charge of a First classA/C seat :1000 Enter the Reservation charge of a First class A/C seat :200 SECOND CLASS A/C *************** Enter the no. of Second Class A/C seats : 50 Enter the charge of a Second ClassA/C seat :750 Enter the Reservation charge of a Second Class A/C seat :150 SLEEPER CLASS *************** Enter the no. of Sleeper Class seats : 100 Enter the charge of a Sleeper Class seat :500 Enter the Reservation charge of a Sleeper Class seat :100 Will there be trip on MONDAYS? (y/n) ? Will there be trip on TUESDAYS? (y/n) ? Will there be trip on WEDNESDAYS? (y/n) ? Will there be trip on THURSDAYS? (y/n) ? Will there be trip on FRIDAYS? (y/n) ? Will there be trip on SATURDAYS? (y/n) ? Will there be trip on SUNDAYS? (y/n) ? Enter travel time : 5 Enter Departure City : THIRUVANANTHAPURAM Enter Destination City : AHMEDABAD Do you want to review the details and then edit ? (y/n) ?

INPUT : (NECESSARY DETAILS), THEN “Y”

Page 62: journey planner

Page 62 of 69

SCREEN 6: TRAIN REVIEW (1/2) RAJADHANI ************* TRAIN NO. : 1234 TRAIN NAME : RAJADHANI FIRST CLASS A/C **************** No. of First Class A/C seats : 5 No. of Reserved First Class A/C seats : 0 Remaining No. of First Class A/C seats : 5 Charge of a First Class A/C seat : 1000 Reservation Charge of a First Class A/C seat : 200 SECOND CLASS A/C **************** No. of Second Class A/C seats : 50 No. of Reserved Second Class A/C seats : 0 Remaining No. of Second Class A/C seats : 50 Charge of a Second Class A/C seat : 750 Reservation Charge of a Second Class A/C seat : 150 SLEEPER CLASS **************** No. of Sleeper Class seats : 100 No. of Reserved Sleeper Class seats : 0 Remaining No. of Sleeper Class seats : 100 Charge of a Sleeper Class seat : 500 Reservation Charge of a Sleeper Class seat : 100 Page 1/2 Press any key to view next page

INPUT : (PRESS ANY KEY)

Page 63: journey planner

Page 63 of 69

SCREEN 7 : TRAIN REVIEW (2/2) There will be trips on : 1. Mondays 2. Tuesdays 3. Fridays 4. Sundays Time for travel : 5 Departure City : THIRUVANANTHAPURAM Destination City : AHMEDABAD Do you want to Edit the details ? (y/n)?

INPUT : “N”

SCREEN 8 : ENTRY CONFIRMATION Entry added

SCREEN 9 : USER MENU 1 . BOOK YOUR TICKET... 2 . CANCEL YOUR TICKET... 3 . VIEW YOUR TICKET... 4 . SEARCH... <<GO TO PREVIOUS MENU [G] [Q] QUIT

INPUT : “1”

Page 64: journey planner

Page 64 of 69

SCREEN 10 : USER TICKET BOOKING(1/4)

SELECT 1 . TRAIN 2 . FLIGHT

INPUT:”1” SCREEN 11: USER TICKET BOOKING(2/4) 1 . 1ST CLASS A/C 2 . 2ND CLASS A/C 3 . SLEEPER CLASS

INPUT : “1” SCREEN 12: USER TICKET BOOKING(3/4) ENTER THE TRAIN NO.1234

SCREEN 13 : USER TICKET BOOKING(4/4) ENTER NAME : REKHA.S

ENTER AGE : 40

Page 65: journey planner

Page 65 of 69

SCREEN 14 : USER TICKET REVIEW

HERE’S YOUR TICKET….. TRAIN ****** TRAIN NO : 1234 SEAT TYPE : 1ST CLASS A/C

TICKET NO. : 3431

NAME : REKHA.S

AGE : 40

FROM : THIRUVANANTHAPURAM TO : AHMEDABAD

Press any key to continue.

INPUT : (PRESS ANY KEY)

SCREEN 15 : EXIT BANNER

||===========================|| || || || THANK YOU FOR USING THE || || JOURNEY PLANNER || || || ||===========================|| ||===========================|| || || || PROJECT DEVELOPED BY || || ********************** || || || || => YASHWANT.R.KAMATH <= || || => YADU KRISHNAN <= || || => AMAL KRISHNA.R <= || || => R.GAUTHAM <= || || ^^^^^^^^^^^^^^^^^^^ || ||===========================|| NOW EXITING....

Page 66: journey planner

Page 66 of 69

Limitations

The limitations which could not be avoided are as

follows:

1.Unability to book multiple tickets at once.

2.No “Search” option to searc for a flight/train.

3.Booked ticket cannot be viewed.

4.Set password cannot be changed, but the file has

to be deleted to reset.

Page 67: journey planner

Page 67 of 69

SYSTEM REQUIREMENTS

The minimum requirements nedded to run the above program are as follows :

OS : Windows® 98 or above RAM : 64 MB or above

Screen Resolution : 1024x600 Speakers : optional Graphics : Atleast 32 MB Memory : 10 MB in C:\

Page 68: journey planner

Page 68 of 69

BIBILIOGRAPHY

Computer Science with C++ : Sumita Arora

Page 69: journey planner

Page 69 of 69