Anda di halaman 1dari 15

RED ROSES PUBLIC SCHOOL

D-Block, Saket, New Delhi-17

COMPUTER SCIENCE
PROJECT
FLIGHT MANAGEMENT

Submitted By
SUBANSHU BABBAR
Class: XII-A

Under the Guidance of


Mrs. Shalini Bhatnagar
PGT (Computer Science)
CERTIFICATE

This is to certify that SUBANSHU BABBAR


of Class XII A has prepared the report on the Project entitled
“FLIGHT MANAGEMENT”.
The report is the result of his efforts & endeavors. The report
is found worthy of acceptance as final project report for the
subject Computer Science of Class XII. He has prepared the
report under my guidance.

(Mrs. Shalini Bhatnagar)


PGT (Computer Science)
Red Roses Public School
Saket, New Delhi
ACKNOWLEDGEMENT

I would like to express a deep sense of thanks & gratitude


to my project guide Mrs. Shalini Bhatnagar Mam for guiding
me immensely through the course of the project. He always
evinced keen interest in my work. Her constructive advice &
constant motivation have been responsible for the successful
completion of this project.

My sincere thanks goes to Mrs. Anuradha Mehta, Our


Principal Mam, for her co-ordination in extending every
possible support for the completion of this project.
I also thanks to my parents for their motivation & support.
I must thanks to my classmates for their timely help &
support for compilation of this project.
Last but not the least, I would like to thank all those who
had helped directly or indirectly towards the completion of
this project.

SUBANSHU BABBAR
Class XII A
INTRODUCTION TO PROJECT

Every Airlines needs to maintain a database of the flights


available. This database usually contains information like
flight number, departure and arrival timing.

“Flight Management” Project is developed by Subanshu


Babbar XII A of Red Roses Public School, Saket as a part of
the curriculum of XII standard CBSE.

Using this C++ Program, the database on the flights can be


created or modified. The same can be used to search the
availability of various flights
Requirements:
1. Hardware requirements
a) Ram – 512 or greater
b) CPU – 2 GHZ or greater
c) Hard Disk Space – 40 GB or greater
2. Software Requirements
a) Turbo C++ or
b) Code Blocks
Limitations:
a) The program cannot store huge amount of data like some
other software – My SQL, Oracle, etc.
b) The program doesn’t give details about all consumers
separately.
c) The program doesn’t give details about mode of payment
d) It works as a single user software as it is created on DOS
based software.
CONTENTS
---------------------------------------------

1. Header Files Used…………………………….

2. Files Generated…………………………………

3. Working Description……………………..

4. Coding…………………………………………………

5. Output…………………………………………………

6. Bibliography……………………………………….
Header Files
--------------------------

1. IOSTREAM.H – for cin and cout

2. FSTREAM.H – for file handling

3. CONIO.H – for clrscr() and getch() functions

4. STUDIO.H – for gets() and puts() functions

5. STRING.H – for strcmp() and strcpy() functions

6. PROCESS.H – for exit() function

7. IOMANIP.H – for setw() function


Files Generated
---------------------------

DATA FILES
 Flc.dat

PROGRAM FILE
Flight.CPP

OBJECT FILE
Flight.obj

EXECUTION FILE
Flight.exe
WORKING DESCRIPTION
---------------------------------------
The Program consists of options as follows:
 Enter a flight
 Show Flights
 Search Flights
 Delete flights
 Modify flight
 Exit
CODING
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<iomanip.h>
#include<fstream.h>
#include<process.h>
#include<stdio.h>
class flight{ //class containing details of flights
int flno; //private members
char from[20];
char to[20];
int dtime;
int atime;
public: //public functions
int flightno(){return flno;} ;
void getdata()
{cout<<"Enter flight no. \n"; cin>>flno;
cout<<"Departure Place\n"; gets(from);
cout<<"Destination Place\n" ; gets(to);
cout<<"Departure Time\n"; cin>>dtime;
cout<<"Arrival Time\n" ; cin>>atime;
}
void showdata ()
{cout<<"\n\n\nFlight : "<<flno;
cout<<"\nDeparture Place : "<<from;
cout<<"\nDestination Place : "<<to;
cout<<"\nDeparture Time : "<<dtime;
cout<<"\nArrival Time : "<<atime;
}
int filno()
{return flno;}
void searchfile(); //function definitions
void writefile();
void readfile();
void deletefile();
void modify();
}a;

void main()
{clrscr();

int op=0;
while (op<=5)
{
clrscr(); //menu for option selection
cout<<"\t\t\t\t\\\\\\\\\ S&S Airways\\\\\\\\ \n\n";
cout<<"Select option:";
cout<<"\n\n 1. Enter a flight";
cout<<"\n 2. Show flights";
cout<<"\n 3. Search flights" ;
cout<<"\n 4. Delete flights" ;
cout<<"\n 5. Modify flight" ;
cout<<"\n 6. Exit \n";
cin>>op;
if (op==1)
{clrscr();
a.writefile(); }
if (op==2)
{clrscr();
cout<<"\nFlight available currently are:\n\n" ;
a.readfile();}
getch();
if (op==3)
{clrscr();
a.searchfile();
getch();
}
if (op==4)
{clrscr();
a.deletefile();
getch();
}
if (op==5)
{clrscr();
a.modify();}
}}

void flight::writefile() //function to write file


{
ofstream f;
f.open("flc.dat", ios::out|ios::app|ios::binary) ;
a.getdata();
f.write((char*) &a, sizeof (a));
f.close();
}
void flight::readfile() //function to read file
{
ifstream f;
f.open("flc.dat", ios::in|ios::binary) ;
while (f.read((char*) &a, sizeof(a)))
{
a.showdata();}getch();
f.close();
}

void flight::searchfile() //function to search file


{
int sn,b;
ifstream f("flc.dat",ios::in);
cout<<"Enter Flight no to be searched for";
cin>>sn;
while(f.read((char*) &a, sizeof(a)))
{if (a.flightno()==sn)
{cout<<"\n\nFlight found successfully!!!!";
a.showdata();
}}}

void flight ::deletefile() //function to delete file


{ int fln;char ch;

fstream f("flc.dat",ios::in) ;
fstream file("temp.dat",ios::out);
cout<<"Enter flight no to be deleted" ;
cin>>fln;
while(f.read((char*) &a, sizeof(a)))
{if (a.filno()==fln)
{a.showdata();
cout<<"Are you sure you want to delete this flight? (y/n)";cin>>ch;
if (ch=='n')
file.write((char*) &a,sizeof(a));
}
else file.write((char*) &a,sizeof(a));
}
file.close();
f.close();
remove("flc.dat");
rename("temp.dat","flc.dat");
}
void flight::modify() //function to modify flight
{ fstream f("flc.dat",ios::in|ios::out|ios::binary);
int fln;
long pos;
char fr[20],tr[20] ;
int at,dt;
cout<<"Enter flight no. of flight to be modified";cin>>fln;
while (!f.eof())
{pos=f.tellg();
f.read((char*) &a, sizeof(a));
if (a.filno()==fln)
{a.showdata();
cout<<"\n\nEnter '.' if you want to retain the old one";
cout<<"\nEnter New Departure Place"; gets(fr);
cout<<"\nEnter New Destination Place"; gets(tr);
cout<<"\n\n Enter -1 to retain old one";
cout<<"\nEnter New Departure Time"; cin>>dt;
cout<<"\nEnter New Arrival Time"; cin>>at;
if (strcmp(fr,".")!=0)
strcpy(from,fr);
if (strcmp(tr,".")!=0)
strcpy(to,tr);
if (dt!=-1 )
dtime=dt;
if (at!=-1)
atime=at;
}
f.seekg(pos);
f.write((char*) &a, sizeof(a));
}}
OUTPUT
BIBLIOGRAPHY
--------------------------------

 Computer Science with C++ by Sumita Arora

 www.stackoverflow.com

 www.cplusplus.com

 www.slideshare.net

Anda mungkin juga menyukai