Sie sind auf Seite 1von 32

Booking tour bus

(Computer Project)

Made By
Aman Tiwari
Roll No :

Session: 2019-20

Submitted to
Mr. Sanjeev Kumar

Nav Jeewan Model Senior Secondary


School
Certificate

This is to certify that the “Booking tour bus” is made by Aman Tiwari Roll No:
Under my supervision and Guidance. This is their authentic work for the partial fulfillment of
computer project work under the C.B.S.E. computer Practical Examination for the session
2019-20.

( Sanjeev Kumar )
Acknowledgment

This is the right time to express our gratitude towards our teachers/ mentor for their constant
support and guidance. These are only a few words which we have written here to show our
respect to our teachers.

Though they will not among us after this session their lesson will always guide us in the future
also.

This project is ours, but it is their inspiration and constant push that we are now able to
compile the whole knowledge we learned throughout 11 & 12 classes, in the form of this
project.

Last but not least sir we would love to say thank you.

Yours Sincerely

[ Aman Tiwari ]
Index
1. certificate
2. Acknowledgment
3. About C++
4. program source code
5. outputs
About C++
The C++ programming language has a history going back
to 1979 when Bjarne Stroustrup was doing work for his
Ph.D. thesis. One of the languages Stroustrup had the
opportunity to work with was a language called Simula,
which as the name implies is a language primarily
designed for simulations. The Simula 67 language - which
was the variant that Stroustrup worked with - is regarded
as the first language to support the object-oriented
programming paradigm. Stroustrup found that this
paradigm was very useful for software development,
however, the Simula language was far too slow for
practical use.

Shortly thereafter, he began work on "C with Classes",


which as the name implies was meant to be a superset of
the C language. His goal was to add object-oriented
programming into the C language, which was and still is a
language well-respected for its portability without
sacrificing speed or low-level functionality. His language
included classes, basic inheritance, inlining, default
function arguments, and strong type checking in addition
to all the features of the C language.

The first C with Classes compiler was called Cfront, which


was derived from a C compiler called CPre. It was a
program designed to translate C with Classes code to
ordinary C. A rather interesting point worth noting is that
Cfront was written mostly in C with Classes, making it a
self-hosting compiler (a compiler that can compile itself).
Cfront would later be abandoned in 1993 after it became
difficult to integrate new features into it, namely C++
exceptions. Nonetheless, Cfront made a huge impact on
the implementations of future compilers and on the Unix
operating system.

In 1983, the name of the language was changed from C


with Classes to C++. The ++ operator in the C language is
an operator for incrementing a variable, which gives some
insight into how Stroustrup regarded the language. Many
new features were added around this time, the most
notable of which are virtual functions, function
overloading, references with the & symbol, the const
keyword, and single-line comments using two forward
slashes (which is a feature taken from the language BCPL).
In 1985, Stroustrup's reference to the language entitled
The C++ Programming Language was published. That
same year, C++ was implemented as a commercial
product. The language was not officially standardized yet,
making the book a very important reference. The language
was updated again in 1989 to include protected and static
members, as well as an inheritance from several classes.

In 1990, The Annotated C++ Reference Manual was


released. The same year, Borland's Turbo C++ compiler
would be released as a commercial product. Turbo C++
added a plethora of additional libraries which would have a
considerable impact on C++'s development. Although
Turbo C++'s last stable release was in 2006, the compiler
is still widely used.

In 1998, the C++ standards committee published the first


international standard for C++ ISO/IEC 14882:1998,
which would be informally known as C++98. The
Annotated C++ Reference Manual was said to be a large
influence on the development of the standard. The
Standard Template Library, which began its conceptual
development in 1979, was also included. In 2003, the
committee responded to multiple problems that were
reported with their 1998 standard and revised it
accordingly. The changed language was dubbed C++03.
In 2005, the C++ standards committee released a
technical report (dubbed TR1) detailing various features
they were planning to add to the latest C++ standard. The
new standard was informally dubbed C++0x as it was
expected to be released sometime before the end of the
first decade. Ironically, however, the new standard would
not be released until mid-2011. Several technical reports
were released up until then, and some compilers began
adding experimental support for the new features.

In mid-2011, the new C++ standard (dubbed C++11) was


finished. The Boost library project made a considerable
impact on the new standard, and some of the new
modules were derived directly from the corresponding
Boost libraries. Some of the new features included regular
expression support (details on regular expressions may be
found here), a comprehensive randomization library, a new
C++ time library, atomics support, a standard threading
library (which up until 2011 both C and C++ were lacking),
a new for loop syntax providing functionality similar to for-
each loops in certain other languages, the auto keyword,
new container classes, better support for unions and array-
initialization lists, and variadic templates.
About program.
-Our program gives you the easiest way to book a
tour bus so you can enjoy your time.

-Our program offers you the different moods of


booking tickets and you can easily find your booked
ticket easily.

-In our program, you easily check your detail anywhere


and any time so you can easily reach your destination.
-Our program gives you easy access to you so you can
book and delete your ticket.
-you can found many busses to different destinations
so you can feel comfortable and book the ticket as per
your scheduled.
-Our program offers many busses at cheap prices.
hope you liked our program.
SOURCE CODE:-

#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
class TourBus
{ int bid;
char destination[200];
char time[50];
int max_seats;
int booked;
int fare;
public:
TourBus()
{
bid=0;
max_seats=50;
booked=0;
fare=0;
strcpy(time,"9:10am");
strcpy(destination,"");
}
void input();
void show();
void display();
int getid()
{
return bid;
}
void book()
{
booked++;
}
char* getDestination()
{
return destination;
}
char* getTime()
{
return time;
}
int getBooked(){
return booked;
}
int getMax(){
return max_seats;
}
int getFare()
{
return fare;
}
};
class Ticket
{
char name[50];
TourBus bus;
public:

void generate(char cname[], TourBus tb)


{
strcpy(name,cname);
bus=tb;
}
void display()
{
cout<<"Customer Name "<<name<<endl;
cout<<"Details of Bus "<<endl;
bus.show();
}
};
void TourBus::input()
{
cout<<"Enter bus id ";
cin>>bid;
cout<<"Enter bus destination ";
gets(destination);
cout<<"Enter time of bus ";
cin>>time;
cout<<"Enter fare of the bus ";
cin>>fare;
}
void TourBus::display()
{
cout<<bid<<"\t"<<destination<<"\t"<<time<<"\t"
<<max_seats<<"\t"<<booked<<"\t"<<fare<<"\n";
}
void TourBus::show()
{
cout<<"Bus Id "<<bid<<endl;
cout<<"Desination "<<destination<<endl;
cout<<"Time "<<time<<endl;
cout<<"No. of seats remaining "<<max_seats-
booked<<endl;
}
void main()
{
int ch;
fstream F,G;
TourBus b;
do
{
clrscr();
cout<<"Press 1 - Add a New Tour Bus"<<endl;
cout<<"Press 2 - Show Selected Bus"<<endl;
cout<<"Press 3 - Display All Buses"<<endl;
cout<<"Press 4 - Delete a Bus"<<endl;
cout<<"Press 5 - Book a ticket "<<endl;
cout<<"Press 6 - Display Booked Tickets
"<<endl;
cout<<"Press 7 - Exit "<<endl;
cout<<"Enter your choice ";
cin>>ch;
switch(ch)
{
case 1:
F.open("tour.dat",ios::app | ios::binary);
b.input();
F.write((char*)&b, sizeof(b));
F.close();
cout<<"Bus added Successfully "<<endl;
getch();
clrscr();

break;
case 2:
int id,chk=0;
cout<<"Enter the bus id to be displayed ";
cin>>id;
F.open("tour.dat",ios::in | ios::binary);
if(F.fail())
cout<<"Can't open file "<<endl;
else
{
while(F.read((char*)&b,sizeof(b)))
{
if(b.getid()==id)
{
b.show();
chk=1;
break;
}
}
if(chk==0)
cout<<"Bus not Found"<<endl;
}
F.close();
break;

case 3:
F.open("tour.dat",ios::in | ios::binary);
if(F.fail())
cout<<"Can't open file "<<endl;
else
{
while(F.read((char*)&b,sizeof(b)))
b.display();
}
F.close();
cout<<"Press a key to continue ";
getch();
clrscr();
break;
case 4:
chk=0;
cout<<"Enter the bus id to be deleted ";
cin>>id;
F.open("tour.dat",ios::in | ios::binary);
G.open("temp.dat",ios::out | ios::binary);
if(F.fail())
cout<<"Can't open file "<<endl;
else
{
while(F.read((char*)&b,sizeof(b)))
{
if(b.getid()!=id)
{
G.write((char*)&b,sizeof(b));
}
else
{
b.show();
chk=1;

}
}
if(chk==0)
cout<<"Bus not Found"<<endl;

else
cout<<"Bus Deleted "<<endl;
}
F.close();
G.close();
remove("tour.dat");
rename("temp.dat","tour.dat");
break;
case 5:
char dest[70],cname[50];
int bid;
Ticket t;
cout<<"Enter the destination ";
gets(dest);
F.open("tour.dat",ios::in | ios::out |
ios::binary);
if(F.fail())
cout<<"Can't open file "<<endl;
else
{
while(F.read((char*)&b,sizeof(b)))
{

if(strcmp(b.getDestination(),dest)==0)
{
b.show();
chk=1;
cout<<"Enter the customer
name ";
gets(cname);
b.book();
t.generate(cname,b);
G.open("tickets.dat",ios::app |
ios::binary);
G.write((char*)&t,sizeof(t));
G.close();
F.seekp(F.tellg()-sizeof(b),ios::beg);

F.write((char*)&b,sizeof(b));
cout<<"Ticket booked"<<endl;
getch();
break;
}
}
if(chk==0)
cout<<"No Bus Found"<<endl;
/* if(b.getid()==id)
{
cout<<"booking"<<endl;
break;
} */
}
F.close();
break;
case 6:
cout<<"Booked Tickets "<<endl;
G.open("tickets.dat",ios::in | ios::binary);
if(G.fail())
cout<<"can't open file "<<endl;
else
{
while(G.read((char*)&t,sizeof(t)))
t.display();
}
G.close();
cout<<"Press a key to continue ";
getch();

}
}while(ch!=7);
}
The output of
booking tour
bus

Das könnte Ihnen auch gefallen