Railway Reservation SystemHEADER FILES USED IN PROJECT
#include<fstream.h> #include<iostream.h> #include<conio.h> #include<dos.h> #include<string.h> #include<stdlib.h> #include<ctype.h> #include<stdio.h> #define sgn(x) (x)>0 ? 1 : ( (x)<0 ? -1 : 0 ) int ch,n; struct date d; struct time t; char *west[]={"MUMBAI","GWALIOR","AGRA","BHUSAWAL","EXIT"}; char *north[]={"DELHI","AMBALA","JAMMU-TAWI","SHIMLA","EXIT"}; char *east[]={"HOWRAH","PATNA","DHANBAD","KHARAGPUR","EXIT"}; char *south[]={"BANGALORE","CHENNAI","COIMBATORE","COCHIN","EXIT"}; char *mains[]={"1. NORTHERN RAILWAYS","2. SOUTHERN RAILWAYS","3. EASTERN RAILWAYS","4. WESTERN RAILWAYS","5. QUIT"}; char *each[]={"TICKET BOOKING","INQUIRY","RESERVATION","EXIT"}; char *cls[]={"FIRST CLASS","SLEEPER","SECOND CLASS"}; char *inq[]={"Inquiry","Developers"}; int westp[]={100,300,300,500}; int eastp[]={100,300,300,500}; int northp[]={100,300,300,500}; int southp[]={100,300,300,500}; int seat[4][4]={{10,10,10,10},{10,10,10,10},{10,10,10,10},{10,10,10,10}}; void reserve(int); void fare(int,int,char **,int *,int); void inquiry(void); int move(int x1,int y1,int x2,int y2,char c); int animate(char *title,int x1,int x2,int y1,int y2); int domenu(char **items,int noi,int maxx,int xtob,int ytob); void clearmake(int); void highlight(int in,int noi,int maxx,int xtob,int ytob,char **items); void print(int ypos,char *message); void makebox(int x1, int y1, int x2, int y2); void main() { void ticbook(int); void mainmenu(void); do { mainmenu(); clrscr(); makebox(1,1,79,24); switch(ch) { case 1: print(4," "); animate("NORTHERN",78,4,30,4); animate("RAILWAYS",3,4,41,4); gotoxy(31,7); cout<<"**CHOOSE OPTIONS**"; do { n=domenu(each,4,16,30,10); gotoxy(25,22); switch(n) { case 1: ticbook(1); break; case 2: inquiry(); break; case 3: reserve(1); break; default: break; } }while(n>0&&n<4); n=0; break; case 2: print(4," "); animate("SOUTHERN",78,4,30,4); animate("RAILWAYS",3,4,41,4); gotoxy(31,7); cout<<"**CHOOSE OPTIONS**"; do { n=domenu(each,4,16,30,10); gotoxy(25,22); switch(n) { case 1: ticbook(2); break; case 2: inquiry(); break; case 3: reserve(2); break; default: break; } }while(n>0&&n<4); n=0; break; case 3: print(4," "); animate("EASTERN",79,4,31,4); animate("RAILWAYS",3,4,41,4); gotoxy(31,7); cout<<"**CHOOSE OPTIONS**"; do { n=domenu(each,4,16,30,10); gotoxy(25,22); switch(n) { case 1: ticbook(3); break; case 2: inquiry(); break; case 3: reserve(3); break; default: break; } }while(n>0&&n<4); n=0; break; case 4: print(4," "); animate("WESTERN",78,4,30,4); animate("RAILWAYS",3,4,41,4); gotoxy(31,7); cout<<"**CHOOSE OPTIONS**"; do { n=domenu(each,4,16,30,10); gotoxy(25,22); switch(n) { case 1: ticbook(4); break; case 2: inquiry(); break; case 3: reserve(4); break; default: break; } }while(n>0&&n<4); n=0; break; default: break; } }while(ch>0&&ch<5); ch=0; print(12,"\aBye-Bye"); getch(); } void mainmenu() { clrscr(); makebox(1,1,79,24); print(4,"\aWELCOME TO RAILWAYS"); animate("INDIAN",38,21,38,3); cout<<"\a"; gotoxy(5,8); cout<<"\t\t\t******CHOOSE ZONES******"; ch=domenu(mains,5,22,28,10); } void ticbook(int stat) { clearmake(6); int *pc; char **name; int n; char *opt[]={"PLATFORM TICKETS","ORDINARY TICKETS ","EXIT"}; n=domenu(opt,3,18,16,10); if(n==1) { int nof; clearmake(8); gotoxy(10,10); cout<<"\aFOR HOW MANY PERSONS ? ::"; cin>>nof; gotoxy(10,12); cout<<"\aPAY Rs. "<<(nof*5)<<"/-"; getche(); clearmake(8); return; } else if(n==2) { int chs; int adults,children; int clsv; unsigned long amount; if(stat==1) { name=north; pc=northp; } else if(stat==2){name=south; pc=southp;} else if(stat==3){name=east; pc=eastp;} else {name=west; pc=westp;} clearmake(8); chs=domenu(name,4,12,16,10); clearmake(8); gotoxy(4,8); cout<<"\a<**************ENTER REQUIRED DATAS*****************> "; gotoxy(8,9); cout<<"ENTER NO. OF ADULTS ::\a"; cin>>adults; gotoxy(8,10); cout<<"ENTER NO. OF CHILDREN ::\a"; cin>>children; gotoxy(8,11); cout<<"\aPRESS ANY KEY TO CHOOSE CLASS::"; getche(); clearmake(8); clsv=domenu(cls,3,12,16,10); clearmake(8); amount=2*(4-clsv)*(*(pc+chs-1))*(adults+children/2); gotoxy(4,8); cout<<"PAY AMOUNT :: Rs."<<amount; getche(); clearmake(8); return; } else if(n==3) { clearmake(8); return; } } void reserve(int zone) { clrscr(); char **stations; int *pc; if(zone==1) { stations=north; pc=northp; } else if(zone==2){stations=south; pc=southp;} else if(zone==3){stations=east; pc=eastp;} else {stations=west; pc=westp;} int ch,p; char t; do { clrscr(); makebox(1,1,79,24); print(4,"\a R E S E R V A T I O N C O U N T E R"); ch=domenu(stations,5,12,31,10); if(ch>4||ch<1) { gotoxy(30,18); cout<<"\aYOU ARE TERMINATED :: Press Any Key..."; getche(); clearmake(8); return; } gotoxy(10,wherey()+3); cout<<" \aENTER THE NUMBER OF PEOPLE :-"; cin>>p; if(p>0) { fare(ch,p,stations,pc,zone-1); } gotoxy(10,wherey()+3); cout<<"\aDO YOU WANT TO CHOOSE AGAIN(Y/N) :-"; cin>>t; }while(t=='y'||t=='Y'); clearmake(6); textcolor(15); gotoxy(26,7); cout<<"\a*********** Choose Option ************"; makebox(1,1,79,24); return; } void fare(int ch,int p,char **stations,int *pc,int zone) { char name[30][100]; int i; ch--; clrscr(); makebox(1,1,79,24); print(4," \aR E S E R V A T I O N C O U N T E R"); gotoxy(10,7); if(seat[zone][ch]<p) { gotoxy(20,wherey()+1); cout<<"\aSEATS NOT AVAILABLE !!\n"; gotoxy(20,wherey()); cout<<"\aREMAINING SEATS ARE "<<seat[zone][ch]<<"\n"; return; } seat[zone][ch]-=p; gotoxy(20,wherey()+1); cout<<"\aENTER THE NAMES OF PERSONS:- \n"; for(i=0;i<p;i++) { gotoxy(10,wherey()); cout<<(i+1)<<".\a "; cin>>name[i]; } clearmake(8); gotoxy(30,10); cout<<"CHOOSE CLASS\a"; int k=domenu(cls,3,14,30,12); clrscr(); cout<<"\a\n\n\t*******************************************************\n"; cout<<"\t* I N D I A N R A I L W A Y S *\n"; cout<<"\t*******************************************************\n"; cout<<"\n\t\t FROM :- BOKARO STEEL CITY \n"; cout<<"\t\t TO :- "<< stations[ch]<<"\n"; cout<<"\t\t DISTANCE :- "<< pc[ch]<<"\n"; cout<<"\t\t TOTAL COST :- "<<(unsigned long)(p*5*(4-k)*(pc[ch]))<<"\n"; cout<<"\t*******************************************************\n"; cout<<"\t\t THE FOLLOWING PERSONS HAVE BEEN RESERVED:-\n\n\t\t"; for(i=0;i<p;i++) { gotoxy(10,12+i); cout<<"\n\t\t"; cout<<(i+1)<<"."; cout<<name[i]<<"\n"<<endl<<"\t\t\t\n"; } cout<<"\a\n\t*******************************************************\n"; makebox(1,1,79,24); gotoxy(10,22); } void inquiry() { clearmake(6); int l=5,u=8,r=76,d=22; int i; char ch=' '; char **wint,**k; int uy,dy; int maxlines; int ice; ice=domenu(inq,2,16,35,12); clearmake(6); char *text1[]={ "========================================================================", " \a ******** T I M E - T A B L E ********** ", "-----------------------------------------------------------------------", " UP-TRAINS DOWN-TRAINS ", "----------------------------------------------------------------------", "ARRIVAL|DEPATURE|TRAIN NO.Û NAME OF THE TRAIN ÛTRAIN NO|ARRIVAL|DEPT. ", "------- -------- -------- =================== ------------------------", " 09:50 09:55 2021 SHATABDI EXPRESS 2022 16:50 17:00\a ", " 11:00 11:05 8011 ISPAT EXPRESS 8012 16:00 16:05\a ", " 16:00 16:10 8030 KURLA EXPRESS 8029 09:35 09:50\a ", " 16:35 16:42 2860 GEETANJALI EXP. 2859 10:35 10:45\a ", " 06:30 06:40 2801 PURUSHOTTAM EXP. 2802 20:15 20:25\a ", " 21:50 - 8013 STEEL EXPRESS 8014 - 06:00\a ", " 00:00 00:05 8002 BOMBAY MAIL 8001 02:55 03:00\a ", " - 14:50 8189 TATA ALLEPPY EXP. 8190 10:00 - \a ", " 20:10 20:17 1030 AZAD HIND EXP. 1029 22:50 22:55\a ", " 00:45 00:50 8034 AHMEDABAD EXP. 8033 00:30 00:38\a ", " 00:50 01:00 8005 SAMBALESHWARI EXP 8006 23:22 23:32\a ", " 01:50 02:10 8015 HATIA EXPRESS 8016 01:50 02:10\a ", " 04:50 04:55 8477 UTKAL EXPRESS 8478 21:55 22:05\a ", " 19:15 19:25 8475 NEELACHAL EXP. 8476 08:20 08:30\a ", " - 13:50 8101 PATHANKOT EXP. 8102 12:15 - \a ", " 18:10 19:00 3287 ROURKELA PATNA EXP. 3388 07:45 08:10\a ", " - 07:30 8183 DANAPUR EXP. 8184 17:15 - \a ", " - 21:05 8181 CHAPRA KATIHAR EXP 8182 17:15 - \a ", " - 13:10 3302 DHANBAD EXP. 3301 11:15 - \a ", " 04:15 04:25 5629 CHENNAI GUAHATI EXP.5630 14:10 14:20\a ", "*********************************************************************** ", " ** P A S S E N G E R T R A I N S ------- ** ", "*********************************************************************** ", " 13:00 - 0349 TATA KHARAGPUR 0350 - 14:40\a ", " 08:05 - 0351 TATA KHARAGPUR 0352 - 18:30\a ", " 20:40 - 0353 TATA KHARAGPUR 0354 - 04:15\a ", " 17:40 - 0345 TATA KHARAGPUR 0346 - 09:00\a ", " - 08:25 0440 TATA ASANSOL 0439 13:35 - \a ", " - 18:30 0303 TATA CHAKRADHARPUR 0304 07:40 - \a ", "---------------------------------------------------------------------\a ", }; char *text2[]= { "---------------------------------------------------------------------", "************* SOFTWARE DEVELOPER *************** \a ", "---------------------------------------------------------------------", "THIS SOFTWARE HAS BEEN DEVELOPED BY:-************ \a ", "1.KUMAR UTTKARSH ", ", "---------------------------------------------------------------------", "**THIS PROJECT HAS BEEN ASSIGNED BY *** ", "!!!!!!!!!!!!!\Mr.B.M.L DAS & Mrs. Rashmi Sinha !!!!!!!!!!!!!!!!! ", "( COMPUTER TEACHER , GURU GOBIND SINGH PUBLIC SCHOOL-BOKARO) ", "******************************************************************\a ", " B O O K S F O R R E F E R E N C E --- ", " 1.PROGRAMMING IN C++ \a-ROBERT LAFORE", " 2.COMPUTER SCIENCE \a-OXFORD", " 3.LANGUAGE IN C++ \a-A.K SHARMA ", "*********************************************************************", " W I T H T H A N K S ", " H A V E A N I C E J O U R N E Y \a\a ", "=====================================================================", }; if(ice==1) { maxlines=37-1; wint=text1; } else { maxlines=23-1; wint=text2; } textcolor(15); textbackground(0); makebox(l-1,u-1,r+1,d+1); window(l,u,r,d); textcolor(12); textbackground(1); k=wint; uy=0;dy=d-u; cprintf("%s",*(wint++)); for(i=uy;i<dy;i++) { cprintf("\r\n%s",*(wint++)); } while(ch!=13) { ch=getch(); if(ch==72) { if(uy>0) { gotoxy(1,1); insline(); cprintf("%s\r\n",*(k+(dy)-(d-u)-1)); uy--; dy--; } } else if(ch==80) { if(dy<maxlines) { gotoxy(1,d-u+1); cprintf("\r\n"); insline(); cprintf("%s\r",*(k+dy+1)); uy++; dy++; } } } textcolor(15); textbackground(0); clrscr(); window(1,1,80,25); clearmake(6); } int move(int x1,int y1,int x2,int y2,char c) { char buff[2]; int x,y; if(x1==x2) { gettext(x1,y1,x2,y1,buff); int oldy=y1; for(y=y1;y!=y2;y+=sgn(y2-y1)) { puttext(x1,oldy,x2,oldy,buff); gettext(x1,y,x2,y,buff); gotoxy(x1,y); putch(c); delay(5); oldy=y; } } else if(y1==y2) { gettext(x1,y1,x1,y2,buff); int oldx=x1; for(x=x1;x!=x2;x+=sgn(x2-x1)) { puttext(oldx,y1,oldx,y2,buff); gettext(x,y1,x,y2,buff); gotoxy(x,y1); putch(c); delay(5); oldx=x; } } return(0); } int animate(char *title,int x1,int y1,int x2,int y2) { int len,i; len=strlen(title); for(i=0;i<len;i++) { if(x1==x2) { move(x1+i,y1,x2+i,y2,title[i]); } else if(y1==y2) { move(x1,y1,x2+i,y2,title[i]); } } return(0); } domenu(char **items,int noi,int maxx,int xtob,int ytob) { int in=0; char gch=0; makebox(xtob,ytob,xtob+maxx+2,ytob+noi+1); makebox(61,2,76,4); getdate(&d); makebox(2,2,12,4); gotoxy(3,3); cprintf("%d-%d-%d",d.da_day,d.da_mon,d.da_year); gotoxy(40,19); highlight(in,noi,maxx,xtob,ytob,items); while(gch!=13&&gch!=27) { while(!kbhit()) { gettime(&t); gotoxy(62,3); cprintf("%2d:%02d::%02d::%02d",t.ti_hour,t.ti_min,t.ti_sec,t.ti_hund); } gch=getch(); if(gch==72) { in--; } else if(gch==80) { in++; } if(in<0) { in=noi-1; } if(in>noi-1) { in=0; } highlight(in,noi,maxx,xtob,ytob,items); } if(gch==13) {return(in+1);} else {return(0);} } void highlight(int in,int noi,int maxx,int xtob,int ytob,char **items) { int x,y,i; textcolor(0); textbackground(0); for(x=xtob;x<maxx;x++) { for(y=ytob;y<noi;y++) { gotoxy(x,y); cprintf(" "); } } textcolor(15); for(i=0;i<noi;i++) { gotoxy(xtob+2,ytob+1+i); if(i==in) { textcolor(0); textbackground(15); cprintf("%s",*(items++)); textbackground(0); textcolor(15); } else { cprintf("%s",*(items++)); } } textcolor(15); textbackground(0); } void clearmake(int row) { int x,y; for(x=2;x<=78;x++) { for(y=row;y<24;y++) { gotoxy(x,y); cprintf(" "); } } } void makebox(int x1, int y1, int x2, int y2) { int x=0,y=0; gotoxy(x1,y1); cout<<"É"; gotoxy(x2,y1); cout<<""; gotoxy(x2,y2); cout<<"1/4"; gotoxy(x1,y2); cout<<"È"; for(x=1;x<x2-x1;x++) { gotoxy(x1+x,y1); cout<<"Í"; gotoxy(x1+x,y2); cout<<"Í"; } for(y=1;y<y2-y1;y++) { gotoxy(x1,y1+y); cout<<"º"; gotoxy(x2,y1+y); cout<<"º"; } gotoxy(30,1); cout<<"Û Project Railways Û"; } void print(int ypos,char *message) { int xpos; int len; len=strlen(message); xpos=(80-len)/2; gotoxy(xpos,ypos); textcolor(10+BLINK); cprintf("%s",message); textcolor(14); makebox(xpos-2,ypos-1,xpos+len+1,ypos+1); } |
INDEX
Contents Page Number
Name of the project Certificate Acknowledgement Source Code Output Bibliography RAILWAY RESERVATION SYSTEM
|