0% found this document useful (0 votes)
69 views15 pages

Computer Science: Investigatory Project

This project develops a C++ program for railway ticket reservation using object-oriented programming and file handling. The program allows users to add new railway stations, book tickets between stations, modify the database of trains, and change the fare rates. Object classes are used to define stations with attributes like name, distance, and fare. File input/output stream functions allow data to be read from and written to external data files for storage and retrieval of station information. The concise menu-driven program demonstrates basic concepts of OOP and file I/O.

Uploaded by

Ashish Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views15 pages

Computer Science: Investigatory Project

This project develops a C++ program for railway ticket reservation using object-oriented programming and file handling. The program allows users to add new railway stations, book tickets between stations, modify the database of trains, and change the fare rates. Object classes are used to define stations with attributes like name, distance, and fare. File input/output stream functions allow data to be read from and written to external data files for storage and retrieval of station information. The concise menu-driven program demonstrates basic concepts of OOP and file I/O.

Uploaded by

Ashish Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Computer Science

Investigatory Project
On Railway Ticket
Reservation

DHANANJAY SOLANKI
12-A
ACKNOWLEDGEMENT
I would like to express a deep sense of
thanks and gratitude to my computer science
teacher Mr. VARUN ANAND for guiding me
immensely through the course of my
project. His constructive advice and
constant motivation have been responsible
for the successful completion of my project.
My sincere thanks to my parents for their
motivation and support. I must thank my
classmates for their timely help and support
for compilation of this project.
OBJECTIVE

The objective of this project is to develop a C++


project on Railway Ticket Reservation
Service using object oriented programming and
data file handling.
INTRODUCTION
C++ is a general purpose programming language. It
has imperative, object oriented and generic
programming features, while also providing the
facilities for low level memory manipulation.
It is designed with a bias for system programming,
with performance, efficiency and flexibility of use as
its design requirements. C++ has also been found
useful in many other contexts, including desktop
applications, servers, performs critical applications.
C++ was designed by Bjarne Stroustrup, a Danish
and British computer trained scientist. It first
appeared in 1983.
CONTENTS

 Header files used


 Working description
 Coding
 Output screens
 Bibliography
HEADER FILES USED

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. <string.h> : for string handling
6. <math.h> : for doing mathematical
operations

WORKING
This program consists of FIVE options as
follows:
1. To add a new railway station
2. To book ticket
3. To change per km rates
4. To modify database of train
5. To exit

CODING
#include<fstream.h>

#include<conio.h>

#include<stdio.h>

#include<math.h>

#include<string.h>

#include<process.h>

char from[30], to[30];

void detail()

cout<<”From”<<endl;

gets(to);

cout<<”To”<<endl;

gets(from);

class railways

char station[60];

unsigned int distance;

float fare;

public:

void ad_data()

cout<<”Enter railway station name”<<endl;


gets(station);

cout<<”Enter its distance from Jammu Tawi”<<endl;

cin>>distance;

void amount(int a, int b, int c)

cout<<”Total distance=”<<fabs((a-b))<<”\n changes per km=”<<c;

fare=fabs((a-b))*c;

cout<<”\n ticket cost=”<<fare;

unsigned int dist()

return distance;

char*station_v()

return station;

void modify()

cout<<”\n Enter new railway station \n”;

gets(station);

cout<<”Enter its distance from Jammu Tawi \n”;


cin>>distance;

} tr;

void main()

clrscr();

unsigned int per_km= 5, choice, d1=0, d2=0,i;

char station_searched[30];

while(1)

clrscr();

cout<<”\n\t\t\t WELCOME TO INDIAN RAILWAYS \n”;

for(i=0; i<100; i++)

cout<<”~”;

cout<<”Enter your choice\n\t 1:~> Add new railway station \n\t2:~> Book
ticket”<<endl;

cout<<”\t3:~>change per km rate \n\t 4:~> Modify database of train \n\t


5:~> exit \n”;

for(i=0; i<100; i++)

cout<<”~”;
}

cin>>choice;

while(choice==1)

ofstream of 1(“train.dat, ios::binary|ios::app);

tr.ad_data();

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

of1.close();

break;

while(choice==2)

ifstream of (“train.dat”, ios::binary);

detail();

while(of1)

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

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

d1=tr.dist();

If(0==strcmp(to, tr.station_v()))

{
d2= tr.dist();

If(d1&&d2)

tr.amount(d1, d2, per_km);

getch();

break;

If(of1.eof())

cout<<”\n stations not found check your spelling \n”;

getch();

of1.close();

break;

If(choice==3)

cout<<”Enter new per km rates”;

cin>>per_km;

if(choice==4)
{

cout<<”enter the railway station to be changed”;

gets(station_searched);

ifstream f1(“train.dat”, ios::binary);

while(f1)

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

long pos=f1.tellg();

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

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

tr.modify();

f1.close();

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

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

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

cout<<”record modified”;

f1.close();

break;

else if(f1.eof())

cout<<”\n Station not found \n”;


getch();

if(choice==5)

cout<<”\n THANK YOU FOR USING INDIAN RAILWAYS”;

getch();

exit(0);

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

cout<<”entered wrong choice PROGRAM IS ABORTING!!!!!!”;

getch();

exit(0);

getch();

}
BIBLIOGRAPHY

www.google.com
www.projects.icbse.com
www.scribd.com

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy