Beruflich Dokumente
Kultur Dokumente
(Computer Project)
Made By
Aman Tiwari
Roll No :
Session: 2019-20
Submitted to
Mr. Sanjeev Kumar
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.
#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:
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