A simple mini project on bus reservation system written in c++. It provides all the basic functionalities of a bus reservation system. It uses arrays efficiently to fulfill this functionality. Can be used as a mini project by It students.
<%@ LANGUAGE=”C++” %><%
// This is made by Vipin Panicker.
// E-Mail: itsvipin@hotmail.com
#include “conio.h”
#include “stdio.h”
#include “iostream.h”
#include “string.h”
#include “graphics.h”
#include “stdlib.h”
#include “dos.h”
static int p=0;
class a
{
char busn[5],driver[10],arrival[5],depart[5],from[10],to[10],
seat[8][4][10];
public:
void install();
void allotment();
void empty();
void show();
void avail();
void position(int i);
}bus[10];//here we declare the number of buses we can have.
void vline(char ch)
{
for (int i=80;i>0;i–)//Here i’s value will depend on your computer.
cout<
cout<<"\n Enter Driver's name: ";
cin>>bus[p].driver;
cout<<"\n Arrival time: ";
cin>>bus[p].arrival;
cout<<"\n Departure: ";
cin>>bus[p].depart;
cout<<"\n From: \t\t\t";
cin>>bus[p].from;
cout<<"\n To: \t\t\t";
cin>>bus[p].to;
bus[p].empty();
p++;
}
void a::allotment()
{
int seat;
char number[5];
top:
cout<<"Bus no: ";
cin>>number;
int n;
for(n=0;n<=p;n++)
{
if(strcmp(bus[n].busn,number)==0)
break;
}
while(n<=p)
{
cout<<"\n Seat number: ";
cin>>seat;
if (seat>32)
{
cout<<"\n There are only 32 seats available in this bus.";
}
else
{
if (strcmp(bus[n].seat[seat/4][(seat%4)-1],"Empty")==0)
{
cout<<"Enter passanger's name: ";
cin>>bus[n].seat[seat/4][(seat%4)-1];
break;
}
else
cout<<"The seat no. is already reserved.\n";
}
}
if (n>p)
{
cout<<"Enter correct bus no.\n";
goto top;
}
}
void a::empty()
{
for(int i=0;i<8;i++)
{
for(int j=0;j<4;j++)
{
strcpy(bus[p].seat[i][j],"Empty");
}
}
}
void a::show()
{
int n;
char number[5];
cout<<"Enter bus no: ";
cin>>number;
for(n=0;n<=p;n++)
{
if(strcmp(bus[n].busn,number)==0)
break;
}
while (n<=p)
{
vline('*');
cout<<" Bus no: \t"<
cout<<"enter correct bus no.";
}
void a::position(int l)
{
int s=0,p=0;
for(int i=0;i<8;i++)
{
cout<<"\n";
for(int j=0;j<4;j++)
{
s++;
if(strcmp(bus[l].seat[i][j],"Empty")==0)
{
cout.width(5);
cout.fill(' ');
cout< “;
cin>>w;
switch(w)
{
case 1:
bus[p].install();
break;
case 2:
bus[p].allotment();
break;
case 3:
bus[0].show();
break;
case 4:
bus[0].avail();
break;
case 5:
exit(0);
}
}
}