RAILWAY ENQUIRY AND RESERVATION SYSTEM CERTIFICATE This is to certify that Piyush Kumar of class XII - B has completed this project titled Railway Enquiry and Reservation System under my guidance in the computer lab during the year 2013-2014. Date: Submitted for CENTRAL BOARD OF SECONDRY EDUCATION Examination held in Computer Lab at KENDRIYA VIDYALAYA BHEL HARIDWAR. Examiner: Seal: Mr. Navneet Singh ACKNOWLEDGEMENT I bestow my hearted appreciation and gratefulness to the efforts made by my Computer Science Teacher: Mr. Navneet Singh, in terms of the Project Idea, instruction and the opportunity, without which my efforts would have remained astray. His unflagging patience, creativity and immense knowledge that he shared with me have proved highly beneficial to me and have made my Project File possible and successful. Piyush Kumar XII - B INDEX 1.Introduction a. Motivation b.Scope / Feasibility c. Functionality 2.Implementation a. Referential Diagram b.Schemas and Data Dictionary c. Data Flow d.Session Management e.Performance Analysis 3.External Interface Requirements 4.Notes and suggested future work 5.Header files used and their purpose 6.Coding in C++ INTRODUCTION This project aims at development of an Online Railway Reservation Utility which facilitates the Railway customers to manage their reservations online, and the Railway administrators to modify the backend databases in a User-Friendly manner. The Customers are required to register on the server for getting access to the database and query result retrieval. Upon registration, each user has an account which is essentially the view level for the customer. The account contains comprehensive information of the user entered during registration and permits the customer to get access to his past reservations, enquire about travel fare and availability of seats, make afresh reservations, update his account details, etc. The Railway Administrator is the second party in the transactions. The administrator is required to login using a master password, once authenticated as an administrator, one has access and right of modification to all the information stored in the database at the server. This includes the account information of the customers, attributes and statistics of stations, description of the train stoppages and physical description of coaches, all the reservations that have been made, etc. The railway administrator has the right to modify any information stored at the server database. o MOTIVATION This project is dedicated to model the existing Railway/(other) reservation systems provide a comprehensive set of features to enhance their operational limits evaluate their performance in different scenarios suggest modifications for greater efficiency o SCOPE AND FEASIBILITY Implementations of this project idea are in industrial use in the form of www.irctc.co.in, etc. Hence, this can be used for suggesting improvements in design, performance and greater usability. Apart from the industrial applications mentioned above, it is a research oriented project as well, the task of performance evaluation of different database designs, for efficiency, is in this spirit. o FUNCTIONALITY The Customer and the Railway Administrator are the two parties which interact with the database, who have different view level schemas to the database information.
Customer Services
i. Create an account by registering, modify account details, deregister from the services ii. Make afresh multi passenger reservations, the customers are provided to choose their berths/reservation spots rather than being randomly allocated positions iii. View , modify or cancel past reservations iv. Customers are provided with different reservation status, just as in real life systems v. Consumers are informed, through emails, about updates in the reservations and trains vi. Consumers are informed about the various seasonal offers and discounts.
Administrator Services i. Add new train services or update the existing train services, e.g. modifying their stopping stations, stoppage times, tariffs, etc. ii. Add or update the physical description of trains, like number of coaches, type of coaches, number of berths, etc. Update information about addition of railway stations, add new railway stations, drop existing railway stations, etc. iv. Access and modify customer accounts or customer reservations. o REFERENTIAL DIAGRAM o DATA DICTIONARY <User> e.g.(ssidha, rashish) <train>n e.g.(2300n, 2200n) <train>c e.g.(2300n, 2200n) Authentication globalreservations Attribute Type Constraints References Pnrno Integer Primary key Pnrno of globalreservations Attribute Type Constraints References Station Arrivaltim e Stopnum Varchar(4 ) Time Integer Primary key - Candidate key Stationacronym of stationinfo - - Attribute Type Constraints References Coachnu m coachtyp e coachcap integer varchar(4 ) Integer Primary key - - Stationacronym of stationinfo - - Attribute Type Constraints References Usernam e Password Varchar(4 ) varchar(4 ) Primary key Not NULL - - Attribute Type Constraints References pnrno startingstatio n endingstation trainno date username pass1_nam e pass1_age pass1_coachnu m pass1_waitnum pass1_berthnum pass1_status pass2_name pass2_age pass2_coachnu m pass2_waitnum pass2_berthnu m pass2_status pass3_name pass3_age pass3_coachnu m pass3_waitnum integer varchar(4) varchar(4) integer integer varchar(20 ) varchar(20 ) integer integer integer integer integer varchar(20 ) integer integer integer integer integer varchar(20 ) integer integer integer Primary key Not NULL Not NULL Not NULL Not NULL Not NULL Not NULL Not NULL Not NULL Not NULL Not NULL Not NULL - - - - - - - - - - - Stationacronym of stationinfo Stationacronym of stationinfo trainno of globaltrains - Username of authentication - - Coachnum of <trainno>c, <train>_<date> - - - - - Coachnum of <trainno>c, <train>_<date> - - - - - Coachnum of <trainno>c, <train>_<date> - pass3_berthnum pass3_status integer integer - - - - globaltrains stationinfo <trainno>_<date> e.g. (2300_101, 2400_102) Notes: i. For each customer / user, there is a file named <username> of the user which stores the PNR number of all recent the user has made. The details of the reservation can be obtained by performing a natural join with the globalreservations table. The table is updated on new reservation being made and an existing reservation being cancelled. ii. For each train, there are 2 tables which describe the train, a. <train>n This stores the stations at which a train stops, the arrival times at the stations and the stop numbers of the stations. This is required to provide the facility to a customer of being able to make reservations for intermediate stops and need not book the ticket for the whole journey. Upon a request for showing trains to book a journey, a query is made to each <train>n table Attribute Type Constraints References trainno startstation endstation starttime endtime integer varchar(4) varchar(4) time time Primary key Not NULL Not NULL Not NULL Not NULL - Stationacronym of stationinfo Stationacronym of stationinfo Arrivaltime of <trainno>n Arrivaltime of <trainno>n Attribute Type Constraints References Stationacronym stationname varchar(4) varchar(20) Primary key - - - Attribute Type Constraints References coachno available cap_str waiting Integer integer varchar(100) integer Primary key Not NULL Not NULL - Coachnum of <trainno>c - - - to match the stations and the stoppage number ensures that the train arrives at the starting station before the ending station. This can be updated only by the administrator. A new table of such type is created and the records are inserted upon the request by the administrator to announce a new train route. To ensure the integrity of the table the administrator is provided with a drop down box for choosing stations to protect from the accidental error of entering non-existent stations. b. <train>c This stores the physical description of the coach types available in the train. It stores the coach number of a coach, the respective coach capacity and the coach type. This is to provide the customers with the flexibility of choosing the coach type. This also enables the administrator to make new types of coaches available to the customer for bookings. When the customer is provided with a list of trains that serve a particular station pair (route), then he is provided with the facility of viewing the coach types of various classes in the train which he selected from the list. This can be updated only by the administrator. A new table of such type is created and the records are inserted upon the request by the administrator to announce a new train route. iii. Each user is provided with an account, which is used for session management, the authentication table stores the account information for each user. The customer / user is provided to view and make reservations only when he enters a legitimate username and password pair. Upon a successful authentication, a php session is initiated. This table is updated upon registration of a new customer, deregistration of an existing customer or by means of a change in password request by an existing user. iv. The whole database is centred about the table globalreservations, this table stores the complete details of all recent reservations. It stores the boarding and de-boarding stations, arrival times, date of journey, passenger list, the coach and berths allotted, etc. To ensure the integrity of this table, the users are provided with drop down boxes to choose stations and date. This table is modified upon reservation, cancellation, update in reservation of existing reservations, which may be explicit in the form of changing the passenger details, or implicit due to change in reservation status from wait list to confirmed. This table is queried upon after being joined with the <user> table when a customer wishes to view his recent reservations. This is undoubtedly the central and the key link relating data entities in the database. v. For making reservations, the table globaltrains consists of the identification details of all existing trains and their routes. In the query to make afresh reservation, this table provides the names of the tables whose station list needs to be searched for finding the in-order station pairs of the journey. vi. Just as for trains, station details are stored in the table named stationinfo. This is used when the administrator tries to input new trains as a service to the customers. This constraints the administrator to choose, the start and ending stations, from a drop down menu and preventing accidental input of non existing stations. vii. Each train and date pair for a recent date, have a table <trainno>_<date> describing the current reservations that have been made in the train <trainno> on date <date>. For each coach, a string of length equal to the capacity of the coach denotes the status of the reservation in it. The string consists of o and e, which essentially flag whether the berth / seat is occupied or empty. New instances are added automatically upon change of date and past tables are dropped. The attribute waiting is stored to store the current count of wait listed reservations that have been booked for a particular coach type for the train on that date.
o DATA FLOW CHART o SESSION MANAGEMENT The data and the files present at the server are password locked. Hence, to gain access to them the user has to pass through the authentication process at index.php / adminauthenticate.php, wherein a php session is initiated and the relevant session variables get initiated. If a client tries to access the locked files without starting a session, it is denied access and redirected to request for starting a session. PERFORMANCE ANALYSIS In this section, we evaluate the performance depending on the following variables to provide generic expressions rather than measure the times on a particular server-client-network pair Database design in terms of the Normal forms the schemas conform Number of joins, selections, projections, etc. for various forms of queries Average access time over the internet
Terminoly a) N <x> : denotes the number of records in table <x> b) A <v,x> : denotes the number of different values of attribute <v> in table <x>. This is analogous to selectivity of <v> in <x> c) RTT : denotes the average round trip time over the network chosen We make the following assumptions for estimating our reservation engine performance a) The time for equi-join on primary key attributes is proportional to the number of tuples in the result. This assumption is justified as 1 record of a each table will contribute to only 1 output of the result b)The time for equi-join on non key attributes on relation <x> and <y> is proportional to N <x> * N <y> . This serves as a bound c) The time for selection on primary key in table <x> is proportional to log(N <x> ). This is reasonable as we need to scan a path along the B-Tree d)The time for selection on equality of non-key attribute <v> in table <x> is proportional to (N <x> /D <v,x> ) We evaluate the service time of frequent operations i.e. reservation and cancellation. The administrator functions are assumed to be very rare compared to user / customer activities. Cancellation *Bottleneck operation highlighted Activity Operation Time Authentication Selection on authentication Nauthentication + RTT Following HTML link - RTT Selecting from reservations Natural join on globalreservations and <user> Nglobalreservation / A<user> + RTT Selecting other tuples to be updated Search and update tuples Nglobaltrains + RTT (*) Nglobaltrain/Atrainno,date,< train>_<date> + Deallocating Seats Selection from <train>_<date> N<train>_<date> + RTT Database update Update <user>, globalreservations, <train>_<date> N<user> + Nglobalreservations + N<train>_<date> Activity Operation Time Authentication Selection on authentication Nauthentication + RTT Following HTML link - RTT Enter destinations info Selection on stationinfo Nstationinfo + RTT Selecting Train Search in all <train> after selection from globaltrains Nglobaltrains + N<train>*Nglobaltr ains + RTT (*) Selecting Seats Selection from <train>_<date> N<train>_<date> + RTT Database update Update <user>, globalreservations, <train>_<date> N<user> + Nglobalreservations + N<train>_<date> + RTT Reservation *Bottleneck operation highlighted EXTERNAL INTERFACE REQUIRMENTS The database engine can be embedded on a platform using i. An active mySQL server ii. A browser which acts as a client iii. An Apache HTTP server All the mentioned resources are free source and can be obtained easily from the internet. NOTES AND SUGGESTED FUTURE WORK i. We have provided the ability where at max 3 people can be booked reservations for, this may not be desirable. ii. We can extend it to provide multi-train service for connecting 2 stations, i.e. if there is no direct train between 2 stations, then we may use more than 1 train to book our reservations. iii. The analysis assumes conservative and uniform spread of values, this may not hold and more sophisticated tools for estimation should be used. iv. Greater information about the user can be stored and the user may be updated about changes in reservation status upon cancellations, via email HEADER FILES USED AND THEIR PURPOSE 1. FSTREAM.H for file handling, cin and cout 2. PROCESS.H for exit() function 3. CONIO.H for clrscr() and getch() functions 4. STDIO.H for standard I/O operations 5. DOS.H for execution of program 6. STRING.H for string handling 7. GRAPHICS.H for graphical display 8. IOMANIP.Hfor C++ streams I/O manipulators #i ncl ude<f st r eam. h> #i ncl ude<pr ocess. h> #i ncl ude<st dl i b. h> cl ass t r ai n { pr i vat e : i nt t r ai nno, nof af seat , nof asseat , nof f sseat , nof acseat , nof ssseat ; char t r ai nname[ 60] , st ar t i ngpoi nt [ 60] , dest i nat i on[ 60] ; publ i c : t r ai n( ) { t r ai nno=0; nof af seat =0; nof asseat =0; nof f sseat =0; nof acseat =0; nof ssseat =0; st r cpy( t r ai nname, " / 0") ; st r cpy( st ar t i ngpoi nt , "/ 0" ) ; st r cpy( dest i nat i on, " / 0" ) ; } voi d i nput ( ) ; / / To i nput t he det ai l s voi d di spl ay( ) ; / / To di spl ay t he det ai l s i nt r et ur nt r ( ) ; i nt r et ur naf ( ) ; i nt r et ur nas( ) ; i nt r et ur nf s( ) ; i nt r et ur nac( ) ; i nt r et ur nss( ) ; }t r ; i nt t r ai n: : r et ur nt r ( ) { r et ur n t r ai nno; } i nt t r ai n: : r et ur naf ( ) { r et ur n nof af seat ; } i nt t r ai n: : r et ur nas( ) { r et ur n nof asseat ; / / PROGRAM - TRAI N RESERVATI ON #i ndude<i ost r eam. h> #i ncl ude<coni o. h> #i ncl ude<st r i ng. h> #i ncl ude<dos. h> #i ncl ude<st di o. h> Coding of Railway Reservation System } i nt t r ai n: : r et ur nf s( ) { r et ur n nof f sseat ; } i nt t r ai n: : r et ur nac( ) { r et ur n nof acseat ; } i nt t r ai n: : r et ur nss( ) { r et ur n nof ssseat ; } 11 voi d t r ai n: : i nput ( ) { cl r scr ( ) ; got oxy( 10, 10) ; cout < <" ENTER THE TRAI N NUMBER "; got oxy( 57, 10) ; ci n>>t r ai nno; got oxy( 10, 12) ; cout < <" ENTER THE NUMBER OF A/ C FI RST CLASS SEATS" ; got oxy( 57, 12) ; ci n>>nof af seat ; got oxy( 10, 14) ; cout < <" ENTER THE NUMBER OF A/ C SECOND CLASS SEATS"; got oxy( 57, 14) ; ci n>>nof asseat ; got oxy( 10, 16) ; cout < <" ENTER THE NUMBER OF FI RST CLASS SLEEPER SEATS"; got oxy( 57, 16) ; ci n>>nof f sseat ; got oxy( 10, 18) ; cout < <" ENTER THE NUMBER OF A/ C CHAI R CAR SEATS" ; got oxy( 57, 18) ; ci n>>nof acseat ; got oxy( 10, 20) ; cout < <" ENTER THE NUMBER OF SECOND CLASS SLEEPER SEATS"; got oxy( 57, 20) ; ci n>>nof ssseat ; got oxy( 10, 22) ; cout < <" ENTER THE TRAI N NAME"; got oxy( 57, 22) ; get s( t r ai nname) ; got oxy( 10, 24) ; cout <<"ENTER THE STARTI NG POI NT "; got oxy( 57, 24) ; get s( st ar t i ngpoi nt ) ; got oxy( 10, 26) ; cout <<"ENTER THE DESTI NATI ON " ; got oxy( 57, 26) ; get s( dest i nat i on) ; voi d t r ai n: : di spl ay ( ) { cl r scr ( ) ; got oxy( 10, 10) ; cout <<"TRAI N NUMBER "; got oxy( 47, 10) ; cout <<t r ai nno; got oxy( 10, 12) ; cout <<"TRAI N NAME " ; got oxy( 47, 12) ; put s( t r ai nname) ; got oxy( 10, 14) ; cout <<"NO OF A/ C FI RST CLASS SEATS " ; got oxy( 47, 14) ; cout <<nof af seat ; got oxy( 10, 16) ; cout <<"NO OF A/ C SECOND CLASS SEATS " ; got oxy( 47, 16) ; cout <<nof asseat ; got oxy( 10, 18) ; cout <<"NO OF FI RST CLASS SLEEPER SEATS " ; got oxy( 47, 18) ; cout <<nof f sseat ; got oxy( 10, 20) ; cout <<"NO OF A/ C CHAI R CLASS SEATS " ; got oxy( 47, 20) ; cout <<nof acseat ; got oxy( 10, 22) ; cout <<"NO OF SECOND CLASS SLEEPER SEATS " ; got oxy( 47, 22) ; cout <<nof ssseat ; got oxy( 10, 24) ; cout <<"STARTI NG POI NT " ; got oxy( 47, 24) ; put s( st ar t i ngpoi nt ) ; got oxy( 10, 26) ; cout <<"DESTI NATI ON " ; got oxy( 47, 26) ; put s( dest i nat i on) ; got oxy( 10, 28) ; cout <<"PRESS ANY KEY TO CONTI NUE " ; get ch( ) ; } cl ass t i cket s { i nt r esno, t oaf , nof af , t oas, nof as, t of s, nof f s, t oac, nof ac, t oss, nof ss, age; char st at us[ 40] , name[ 40] ; publ i c: t i cket s( ) ; voi d r eser vat i on( ) ; voi d cancel l at i on( ) ; / / For t i cket r eser vat i on / / For t i cket cancel l at i on i nt r et ( ) ; voi d di spl ay( ) ; / / To di spl ay r eser vat i on det ai l s }t i ck; t i cket s: : t i cket s( ) { r esno=0; t oaf =0; nof af =0; t oas=0; nof as=0; t of s=0; nof f s=0; t oac=0; nof ac=0; t oss=0; nof ss=0; age=0; st r cpy( st at us, " / 0" ) ; st r cpy( name, " / 0" ) ; } i nt t i cket s: : r et ( ) { r et ur n r esno; } voi d t i cket s: : di spl ay( ) { i nt f =0; cl r scr ( ) ; i f st r eamf n( " Ti cket 1. dat " , i os: : out ) ; f n. seekg( 0) ; i f ( ! f n) { cout <<"ERROR I N THE FI LE " ; } X: got oxy( 10, 10) ; cout <<"ENTER THE RESERVATI ON NO "; got oxy( 10, 12) ; i nt n; ci n>>n; whi l e( ! f n. eof ( ) ) { f n. r ead( ( char *) &t i ck, si zeof ( t i ck) ) ; got oxy( 10, 10) ; i f ( n==r esno) { cl r scr ( ) ; f =1; got oxy( 10, 10) ; cout < <" NAME "; got oxy( 30, 10) ; cout <<name; got oxy( 10, 12) ; cout <<"AGE " ; got oxy( 30, 12) ; cout <<age; got oxy( 10, 14) ; cout <<"PRESENT STATUS " ; got oxy( 30, 14) ; cout <<st at us; got oxy( 10, 16) ; cout <<"RESERVATI ON NUMBER " ; got oxy( 30, 16) ; cout <<r esno; got oxy( 10, 18) ; cout <<"PRESS ANY KEY TO CONTI NUE " ; get ch( ) ; } } i f ( f ==0) { cl r scr ( ) ; got oxy( 10, 10) ; cout <<"UNRECOGI NI ZED RESERVATI ON NO ! ! ! WANNA RETRY ?( Y/ N) "; char a; got oxy( 10, 12) ; ci n>>a; i f ( a==y| | a==Y) { cl r scr ( ) ; got o X; } el se { got oxy( 10, 12) ; cout < <" PRESS ANY KEY TO CONTI NUE" ; get ch( ) ; } } f n. cl ose( ) ; } voi d t i cket s: : r eser vat i on( ) { cl r scr ( ) ; got oxy( 10, 10) ; cout <<"RESERVATI ON " ; got oxy( 10, 12) ; cout <<"ENTER THE TRAI N NO: " ; i nt t no, f =0; ci n>>t no; of st r eamf i l e; i f st r eamf i n( "Tr ai n1. dat " , i os: : out ) ; f i n. seekg( 0) ; i f ( ! f i n) { cl r scr ( ) ; got oxy( 10, 10) ; cout < <" ERROR I N THE FI LE " ; cl r scr ( ) ; whi l e( ! f i n. eof ( ) ) { f i n. r ead( ( char *) &t r , si zeof ( t r ) ) ; i nt z; z=t r . r et ur nt r ( ) ; i f ( t no==z) { f =1; nof af =t r . r et ur naf ( ) ; nof as=t r . r et ur nas( ) ; nof f s=t r . r et ur nf s( ) ; nof ac=t r . r et ur nac( ) ; nof ss=t r . r et ur nss( ) ; } } i f ( f ==1) { f i l e. open( "Ti cket 1. dat " , i os: : app) ; S: cl r scr ( ) ; got oxy( 10, 10) ; cout <<"NAME: " ; get s( name) ; got oxy( 10, 12) ; cout <<"AGE: " ; ci n>>age; cl r scr ( ) ; got oxy( 10, 10) ; cout < <" SELECT THE CLASS WHI CH YOU WI SH TO TRAVEL"; got oxy( 10, 12) ; cout <<"1. A/ C FI RST CLASS " ; got oxy( 10, 14) ; cout <<"2. A/ C SECOND CLASS " ; got oxy( 10, 16) ; cout <<"3. FI RST CLASS SLEEPER " ; got oxy( 10, 18) ; cout <<"4. A/ C CHAI R CAR " ; got oxy( 10, 20) ; cout <<"5. SECOND CLASS SLEEPER " ; got oxy( 10, 22) ; cout <<"ENTER YOUR CHOI CE " ; got oxy( 30, 22) ; i nt c; ci n>>c; swi t ch( c) { case 1: t oaf ++; r esno=r and( ) ; i f ( ( nof af - t oaf ) >0) { st r cpy( st at us, " conf i r med" ) ; got oxy( 10, 24) ; cout < <" STATUS" ; got oxy( 30, 24) ; put s( st at us) ; got oxy( 10, 26) ; cout <<"RESERVATI ON NO" ; got oxy( 30, 26) ; cout <<r esno; get ch( ) ; f i l e. wr i t e( ( char *) &t i ck, si zeof ( t i ck) ) ; br eak; st r cpy( st at us, " pendi ng" ) ; got oxy( 10, 24) ; cout <<"STATUS"; got oxy( 30, 24) ; put s( st at us) ; got oxy( 10, 26) ; cout <<"RESERVATI ON NO" ; got oxy( 30, 26) ; cout <<r esno; get ch( ) ; f i l e. wr i t e( ( char *) &t i ck, si zeof ( t i ck) ) ; br eak; } case 2: t oas++; r esno=r and( ) ; i f ( ( nof as- t oas) >0) { st r cpy( st at us, " conf i r med" ) ; got oxy( 10, 24) ; cout < <" STATUS" ; got oxy( 30, 24) ; put s( st at us) ; got oxy( 10, 26) ; cout <<"RESERVATI ON NO" ; got oxy( 30, 26) ; cout <<r esno; get ch( ) ; f i l e. wr i t e( ( char *) &t i ck, si zeof ( t i ck) ) ; br eak; st r cpy( st at us, " pendi ng" ) ; got oxy( 10, 24) ; cout <<"STATUS"; got oxy( 30, 24) ; put s( st at us) ; got oxy( 10, 26) ; cout <<"RESERVATI ON NO"; got oxy( 30, 26) ; cout <<r esno; get ch( ) ; f i l e. wr i t e( ( char *) &t i ck, si zeof ( t i ck) ) ; br eak; } case 3: t of s++; r esno=r and( ) ; i f ( ( nof f s- t of s) >0) { st r cpy( st at us, " conf i r med" ) ; got oxy( 10, 24) ; cout < <" STATUS" ; got oxy( 30, 24) ; put s( st at us) ; got oxy( 10, 26) ; cout <<"RESERVATI ON NO" ; got oxy( 30, 26) ; cout <<r esno; get ch( ) ; f i l e. wr i t e( ( char *) &t i ck, si zeof ( t i ck) ) ; br eak; } el se { st r cpy( st at us, " pendi ng" ) ; got oxy( 10, 24) ; cout <<"STATUS"; got oxy( 30, 24) ; put s( st at us) ; got oxy( 10, 26) ; cout <<"RESERVATI ON NO"; got oxy( 30, 26) ; cout <<r esno; get ch( ) ; f i l e. wr i t e( ( char *) &t i ck, si zeof ( t i ck) ) ; br eak; } case 4: t oac++; r esno=r and( ) ; i f ( ( nof ac- t oac) >0) { st r cpy( st at us, " conf i r med" ) ; got oxy( 10, 24) ; cout < <" STATUS" ; got oxy( 30, 24) ; put s( st at us) ; got oxy( 10, 26) ; cout <<"RESERVATI ON NO"; got oxy( 30, 26) ; cout <<r esno; get ch( ) ; f i l e. wr i t e( ( char *) &t i ck, si zeof ( t i ck) ) ; br eak; } el se { st r cpy( st at us, " pendi ng" ) ; got oxy( 10, 24) ; cout <<"STATUS"; got oxy( 30, 24) ; put s( st at us) ; got oxy( 10, 26) ; cout <<"RESERVATI ON NO" ; got oxy( 30, 26) ; cout <<r esno; get ch( ) ; f i l e. wr i t e( ( char *) &t i ck, si zeof ( t i ck) ) ; br eak; } case 5: t oss++; r esno=r and( ) ; i f ( ( nof ss- t oss) >0) { st r cpy( st at us, " conf i r med" ) ; got oxy( 10, 24) ; cout < <" STATUS" ; got oxy( 30, 24) ; put s( st at us) ; got oxy( 10, 26) ; cout <<"RESERVATI ON NO" ; got oxy( 30, 26) ; cout <<r esno; get ch( ) ; f i l e. wr i t e( ( char *) &t i ck, si zeof ( t i ck) ) ; br eak; } el se { st r cpy( st at us, " pendi ng" ) ; got oxy( 10, 24) ; cout <<"STATUS"; got oxy( 30, 24) ; put s( st at us) ; got oxy( 10, 26) ; cout <<"RESERVATI ON NO"; got oxy( 30, 26) ; cout <<r esno; get ch( ) ; f i l e. wr i t e( ( char *) &t i ck, si zeof ( t i ck) ) ; br eak; } } got oxy( 10, 28) ; cout <<"DO YOU WI SH TO CONTI NUE BOOKI NG TI CKETS ( Y/ N) ? " ; got oxy( 57, 30) ; char n; ci n>>n; i f ( n==' y' | | n==' Y' ) { got o S; } } } i f ( f ==0) { cl r scr ( ) ; got oxy( 10, 10) ; cout < <" ERROR I N THE TRAI N NUMBER ENTERED ! ! ! " ; get ch( ) ; } f i l e. cl ose( ) ; } voi d t i cket s: : cancel l at i on( ) { cl r scr ( ) ; i f st r eamf i n; f i n. open( "Ti cket 1. dat ", i os: : out ) ; of st r eamf i l e; f i l e. open( "Temp1. dat ", i os: : app) ; f i n. seekg( 0) ; got oxy( 10, 10) ; cout <<"ENTER THE RESERVATI ON NO "; i nt r , f =0; ci n>>r ; i f ( ! f i n) cout < <" ERROR I N THE FI LE ! ! ! " ; } whi l e( ! f i n. eof ( ) ) { f i n. r ead( ( char *) &t i ck, si zeof ( t i ck) ) ; i nt z; z=r et ( ) ; i f ( z! =r ) { f i l e. wr i t e( ( char *) &t i ck, si zeof ( t i ck) ) ; } i f ( z==r ) { f =1; } } f i l e. cl ose( ) ; f i n. cl ose( ) ; r emove( " Ti cket 1. dat " ) ; r ename( "Temp1. dat " , "Ti cket 1. dat ") ; i f ( f ==0) { got oxy( 10, 12) ; cout <<"NO SUCH RESERVATI ON I S MADE ! ! ! PLEASE RETRY " ; get ch( ) ; } el se { got oxy( 10, 12) ; cout <<"RESERVATI ON CANCELLED"; get ch( ) ; } } voi d mai n( ) { i nt ch, r =1000, j ; cl r scr ( ) ; got oxy( 33, 22) ; cout <<"WELCOME" ; Z: cl r scr ( ) ; got oxy( 25, 8) ; cout <<"RAI LWAY TI CKET RESERVATI ON" ; got oxy( 25, 9) ; cout <<"==========================" ; got oxy( 20, 15) ; cout <<" 1. TRAI N DETAI LS"; got oxy( 20, 17) ; cout <<"2. UPDATE TRAI N DETAI LS " ; got oxy( 20, 19) ; cout <<"3. RESERVI NG A TI CKET "; got oxy( 20, 21) ; cout <<"4. CANCELLI NG A TI CKET"; got oxy( 20, 23) ; cout <<"5. DI SPLAY THE PRESENT TI CKET STATUS "; got oxy( 20, 25) ; cout <<"6. EXI T"; got oxy( 20, 27) ; cout <<"ENTER YOUR CHOI CE: " ; ci n>>ch; char n; swi t ch( ch) { case 1: { i f st r eamf i n( "Tr ai n1. dat " , i os: : out ) ; f i n. seekg( 0) ; cl r scr ( ) ; i f ( ! f i n) { cl r scr ( ) ; got oxy( 10, 10) ; cout < <" ERROR I N THE FI LE ! ! ! " ; } el se { cl r scr ( ) ; whi l e( ! f i n. eof ( ) ) { f i n. r ead( ( char *) &t r , si zeof ( t r ) ) ; t r . di spl ay( ) ; } } f i n. cl ose( ) ; got o Z; } case 2: cl r scr ( ) ; got oxy( 20, 10) ; cout <<"ENTER THE PASSWORD " ; ci n>>j ; got oxy( 20, 30) ; cout < <" CHECKI NG PLEASE WAI T get ch( ) ; } " ; { Y: of st r eamf out ( " Tr ai n1. dat " , i os: : app) ; t r . i nput ( ) ; f out . wr i t e( ( char *) &t r , si zeof ( t r ) ) ; f out . cl ose( ) ; got oxy( 10, 30) ; cout <<"DO YOU WI SH TO CONTI NUE UPDATI NG ?( Y/ N) " ; ci n>>n; i f ( n==y| | n==Y) got o Y; got o Z; } el se got o Z; case 3: t i ck. r eser vat i on( ) ; got o Z; case 4: t i ck. cancel l at i on( ) ; got o Z; case 5: t i ck. di spl ay( ) ; got o Z; case 6: exi t ( 0) ; } get ch( ) ; </ st dl i b> </ pr ocess> </ f st r eam> </ st di o> </ dos> </ st r i ng> </ coni o> </ i ost r eam>