Shaurya Xii Computer
Shaurya Xii Computer
Last but not the least; I would like to thank all those who had
Helped directly or indirectly towards the completion of this project.
SHAURYA TRIPATHI
Class: XII Science
HEADER FILES USED AND THEIR
PURPOSE
C E R T I F I C A T E
CERTIFICATE
public:
clrscr();
for(int i=5;i<31;i++)
{
gotoxy(i,1);
cout<<"*";
}
for(int j=1;j<45;j++)
{
gotoxy(j,40);
cout<<"*";
}
for(int k=1;k<=94;k++)
{
gotoxy(5,k);
cout<<"*";
}
for(int l=1;l<=25;l++)
{
gotoxy(75,l);
cout<<"*";
}
}
int reservation::city() //this city function is used to
{ //display total cost of reservation
int rent;
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Delhi")==0))
{
rent=345;
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Mumbai")==0))
{
rent=796;
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Pune")==0))
{
rent=650;
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Lucknow")==0))
{
rent=16;
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Chandigarh")==0))
{
rent=248;
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Surat")==0))
{
rent=710;
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Howrah")==0))
{
rent=550;
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Jodhpur")==0))
{
rent=623;
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Jammu Tawi")==0))
{
rent=567;
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Patna")==0))
{
rent=190;
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Gorakhpur")==0))
{
rent=165;
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Chennai")==0))
{
rent=2000;
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Etawah")==0))
{
rent=150;
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Ahmedabad")==0))
{
rent=600;
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Puri")==0))
{
rent=650;
}
return rent;
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Delhi")==0))
{strcpy(clas,"AC3");
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Mumbai")==0))
{strcpy(clas,"s2");
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Chandigarh")==0))
{strcpy(clas,"AC1");
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Howrah")==0))
{strcpy(clas,"s4");
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Patna")==0))
{strcpy(clas,"s5");
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Etawah")==0))
{strcpy(clas,"s6");
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Jodhpur")==0))
{strcpy(clas,"AC2");
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Jammu Tawi")==0))
{strcpy(clas,"s1");
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Surat")==0))
{strcpy(clas,"s8");
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Gorakhpur")==0))
{strcpy(clas,"s6");
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Pune")==0))
{strcpy(clas,"s3");
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Puri")==0))
{strcpy(clas,"s7");
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Ahemadabad")==0))
{strcpy(clas,"AC1");
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Lucknow")==0))
{strcpy(clas,"s4");
}
if((strcmpi(from,"Kanpur")==0)&&(strcmpi(to,"Chennai")==0))
{strcpy(clas,"AC3");
}
return clas;
}
case 2:out_reserve();
getch();
clrscr();
break;
case 3:res_enquiry();
getch();
clrscr();
break;
case 4:res_cancel();
getch();
clrscr();
break;
case 5:enquiry();
getch();
clrscr();
break;
case 6:add_train();
getch();
clrscr();
break;
case 7:del_train();
getch();
clrscr();
break;
case 8:exit(0);
break;
} //end of switch
}
while(z<8);
}
void input_reserve()
{
clrscr();
ofstream f("rinfo.dat",ios::binary);
box();
r1.input();
f.write((char*)&r1,sizeof(r1));
f.close();
}
void reservation::input()
{
randomize();
gotoxy(18,3);
cprintf("----------------------------------------");
gotoxy(18,4);
cout<<"Please enter information for reservation";
gotoxy(18,5);
cprintf("----------------------------------------");
gotoxy(8,7);
textcolor(9);
cout<<"Ticket No.::";
gotoxy(8,8);
textcolor(9);
cprintf("Date::");
gotoxy(8,9);
textcolor(9);
cprintf("Train no.::");
gotoxy(8,10);
textcolor(9);
cprintf("Train Name::");
gotoxy(17,13);
cprintf("---------------------------------------");
gotoxy(18,14);
textcolor(9);
cprintf("From station");
gotoxy(34,14);
textcolor(14);
cprintf("|");
gotoxy(35,14);
textcolor(9);
cprintf("to");
gotoxy(37,14);
textcolor(14);
cprintf("|");
gotoxy(45,14);
textcolor(9);
cprintf("Station");
gotoxy(17,16);
cprintf("---------------------------------------");
gotoxy(20,7);
cin>>ticketno;
gotoxy(14,8);
gets(date);
gotoxy(19,9);
cin>>trno;
gotoxy(21,10);
gets(tname);
gotoxy(19,15);
gets(from);
gotoxy(45,15);
gets(to);
gotoxy(8,17);
textcolor(9);
cprintf("Passenger Details->");
gotoxy(30,17);
textcolor(9);
cprintf("Adults::");
cin>>adult;
gotoxy(41,17);
textcolor(9);
cprintf("Child::");
cin>>child;
gotoxy(53,17);
textcolor(9);
cprintf("Total Passengers::");
cin>>nop;
gotoxy(7,18);
cprintf("-------------------------------------------------------------------");
int y=0;
for(int i=0;i<nop;i++,y++)
{
gotoxy(8,19);
cout<<"Name";
gotoxy(30,19);
cout<<"Age";
gotoxy(48,19);
cout<<"Sex(m\f)";
gotoxy(7,20+y);
cout<<i+1<<".";
gotoxy(9,20+y);
gets(name);
gotoxy(30,20+y);
cin>>age[i];
gotoxy(48,20+y);
cin>>sex[i];
seatno[i]=random(5-300+1)+300;
}
chp=coach(clas);
fare=nop*city();
trans=random(400-124524+1)+124524;
pnr=random(50-1245687+1)+1245687;
}
void out_reserve()
{
ifstream f1("rinfo.dat",ios::binary);
int g;
clrscr();
box();
gotoxy(18,2);
cprintf("---------------------------------------");
gotoxy(25,3); //to set X & Y axis
textcolor(6);
cprintf("!!! Have a safe & comfortable journey !!!");
gotoxy(18,4);
cprintf("---------------------------------------");
gotoxy(7,5);
textcolor(4);
cout<<"Enter Your Ticket No.:";
cin>>g;
f1.read((char*)&r2,sizeof(r2));
if(r2.ticketno==g)
{
gotoxy(8,8);
textcolor(6);
cout<<"Date::"<<r2.date;
gotoxy(50,8);
textcolor(6);
cout<<"Class::";
cout<<r2.chp;
gotoxy(8,9);
textcolor(6);
cout<<"Train no.::"<<r2.trno;
gotoxy(8,10);
textcolor(6);
cout<<"Train Name::"<<r2.tname;
gotoxy(17,11);
cprintf("--------------------------------------------");
gotoxy(18,12);
textcolor(6);
cprintf("Boarding At");
gotoxy(19,13);
cout<<r2.from;
gotoxy(34,12);
textcolor(14);
cprintf("|");
gotoxy(35,12);
textcolor(9);
cprintf("to");
gotoxy(37,12);
textcolor(14);
cprintf("|");
gotoxy(45,12);
textcolor(9);
cprintf("Station");
gotoxy(45,13);
cout<<r2.to;
gotoxy(17,14);
cprintf("--------------------------------------------");
int o=0;
gotoxy(6,16);
cprintf("---------------------------------------------------------------------");
for(int j=0;j<r2.nop;j++,o++)
{
gotoxy(8,17);
cout<<"Name";
gotoxy(28,17);
cout<<"Age";
gotoxy(40,17);
cout<<"Sex(m\f)";
gotoxy(50,17);
cout<<"Seat no.";
gotoxy(7,18+o);
cout<<j+1<<".";
gotoxy(9,18+o);
puts(r2.name);
gotoxy(29,18+o);
cout<<r2.age[j];
gotoxy(41,18+o);
cout<<r2.sex[j];
gotoxy(51,18+o);
cout<<r2.seatno[j];
}
gotoxy(8,23);
textcolor(2);
cout<<"T.Cash::Rs.";
cout<<r2.fare;
gotoxy(50,7);
textcolor(2);
cout<<"Trans_ID::";
cout<<r2.trans;
gotoxy(8,7);
textcolor(2);
cout<<"PNR No.::";
cout<<r2.pnr;
char b;
gotoxy(23,25);
cout<<"Press any key to continue...";
getch();
}
else
{ char a;
gotoxy(18,13);
cout<<"WRONG TICKET NUMBER";
gotoxy(18,24);
cout<<"Press any key to continue....";
getch();
}
f1.close();
}
//***********function definition to displey train information************
void train::display()
{
gotoxy(10,10);
cout<<"TRAIN NO.::"<<a;
gotoxy(10,12);
cout<<"TRAIN NAME::"<<b;
gotoxy(10,14);
cout<<"ARR::"<<c;
gotoxy(10,16);
cout<<"DEP::"<<d;
cout<<"Press any key to continue....";
getch();
clrscr();
}
void enquiry()
{
train t2;
int n;
clrscr();
box();
ifstream f10("enquiry.dat",ios::binary);
gotoxy(18,3);
cprintf("---------------------------------------");
gotoxy(26,4);
cout<<"TRAIN ENQUIRY";
gotoxy(18,5);
cprintf("---------------------------------------");
gotoxy(10,6);
cout<<"Enter Train No.";
cin>>n;
while(!f10.eof())
{
f10.read((char*)&t2,sizeof(t2));
if(t2.t==n)
{
t2.display();
getch();
}}
f10.close();
}
void add_train()
{
int v,d=0;
train t7;
clrscr();
box();
gotoxy(15,10);
cout<<"Enter the number of trains to be added";
cin>>v;
ofstream f3("enquiry.dat",ios::app|ios::binary);
while(d<v)
{
t7.e_enter();
f3.write((char*)&t7,sizeof(t7));
d++;
}
d=0;
f3.close();
}
void train::e_enter()
{
clrscr();
box();
gotoxy(20,6);
cprintf("TRAIN ENQUIRY");
gotoxy(8,10);
cout<<"Enter Train No.::";
cin>>a;
t=a;
gotoxy(8,14);
cout<<"Enter Train Name::";
gets(b);
gotoxy(8,18);
cout<<"Enter Arrival Time::";
gets(c);
gotoxy(8,22);
cout<<"Enter Departure Time::";
gets(d);
}
void del_train()
{
int g=0;
train t6;
ifstream f4("einfo.dat",ios::binary);
ofstream f5("einfo1.dat",ios::binary);
int t;
clrscr();
box();
cout<<"Enter Train No.::";
cin>>t;
while(f4)
{
f4.read((char*)&t6,sizeof(t6));
if(t6.a!=t)
{
f5.write((char*)&t6,sizeof(t6));
g=0;
}
else
{
g=1;
}
}
remove("einfo.dat");
rename("einfo1.dat","einfo.dat");
if(g==0)
{
gotoxy(23,8);
cout<<"Wrong Train Number Entered";
gotoxy(23,20);
cout<<"press any key to continue";
getch();
}
else
{
clrscr();
box();
gotoxy(20,15);
cout<<"Entry of Train has been removed";
gotoxy(23,23);
cout<<"Press any key to continue";
getch();
}
f4.close();
f5.close();
}
if(g==0)
{
gotoxy(23,10);
cout<<"Wrong Ticket Number Entered";
gotoxy(25,15);
cout<<"Press any key to continue";
getch();
}
else
{
clrscr();
box();
gotoxy(20,25);
cout<<"Your Reservation Ticket has been Cancelled";
gotoxy(19,38);
cout<<"Press any key to return to main menu";
getch();
}
f7.close();
f8.close();
}
void res_enquiry()
{
clrscr();
box();
int d;
reservation r20;
ifstream f9("rinfo.dat",ios::binary);
gotoxy(18,3);
cprintf("---------------------------------------");
gotoxy(26,4);
cprintf("RESERVATION ENQUIRY");
gotoxy(18,5);
cprintf("---------------------------------------");
gotoxy(7,10);
cout<<"Enter the Ticket No.";
cin>>d;
while(f9.read((char*)&r20,sizeof(r20)))
{
if(r20.ticketno==d)
{
gotoxy(18,13);
cout<<"YOUR RESERVATION IS CONFIRM";
gotoxy(23,25);
cout<<"Press any key to continue...";
getch();
clrscr();
box();
gotoxy(18,3);
cprintf("-----------------------------------------");
gotoxy(18,4);
cprintf("HERE IS YOUR CONFIRMED RESERVATION TICKET");
gotoxy(18,5);
cprintf("-----------------------------------------");
gotoxy(8,8);
textcolor(6);
cout<<"Date::"<<r20.date;
gotoxy(50,8);
textcolor(6);
cout<<"Class::";
cout<<r20.chp;
gotoxy(8,9);
textcolor(6);
cout<<"Train no.::"<<r20.trno;
gotoxy(8,10);
textcolor(6);
cout<<"Train Name::"<<r20.tname;
gotoxy(17,11);
cprintf("--------------------------------------------");
gotoxy(18,12);
textcolor(6);
cprintf("Boarding At");
gotoxy(19,13);
cout<<r20.from;
gotoxy(34,12);
textcolor(14);
cprintf("|");
gotoxy(35,12);
textcolor(9);
cprintf("to");
gotoxy(37,12);
textcolor(14);
cprintf("|");
gotoxy(45,12);
textcolor(9);
cprintf("Station");
gotoxy(45,13);
cout<<r20.to;
gotoxy(17,14);
cprintf("--------------------------------------------");
int o=0;
gotoxy(6,16);
cprintf("---------------------------------------------------------------------");
for(int j=0;j<r20.nop;j++,o++)
{
gotoxy(8,17);
cout<<"Name";
gotoxy(28,17);
cout<<"Age";
gotoxy(40,17);
cout<<"Sex(m\f)";
gotoxy(50,17);
cout<<"Seat no.";
gotoxy(7,18+o);
cout<<j+1<<".";
gotoxy(9,18+o);
puts(r20.name);
gotoxy(29,18+o);
cout<<r20.age[j];
gotoxy(41,18+o);
cout<<r20.sex[j];
gotoxy(51,18+o);
cout<<r20.seatno[j];
}
gotoxy(8,23);
textcolor(2);
cout<<"T.Cash::Rs.";
cout<<r20.fare;
gotoxy(50,7);
textcolor(2);
cout<<"Trans_ID::";
cout<<r20.trans;
gotoxy(8,7);
textcolor(2);
cout<<"PNR No.::";
cout<<r20.pnr;
gotoxy(23,25);
cout<<"Press any key to continue...";
getch();
}
else
{
gotoxy(18,13);
cout<<"YOUR RESERVATION IS NOT CONFIRM";
gotoxy(18,24);
cout<<"Please press any key to view your ticket....";
getch();
clrscr();
box();
}
}
f9.close();
}
//*****************************END OF
PROGRAM*******************************
REQUIREMENTS
HARDWARE REQUIRED
SOFTWARE REQUIRED