Page

Railway Ticket Reservation System In C,C++

#include<iostream.h>
#include<stdio.h>
#include<stdio.h>
#include<conio.h>
#include<dos.h>
int rep;
int i;
int ia=12,sa=13,isa=5;
float am=0;
class reser
{
public:

char nam[20][10], add[30][30];
int rep;
int i;
float cost[10];
int choice[10];


void menu();
void calculation();
void choicetable();
void output();
void total();

}res;

void reser:: menu()
{
clrscr();
cout<<"*********************************Menu List*************************************" ;
cout<<"\n\nS.No.  Name \t\t No of Seats \t Cost per Seat \t From \t To\n";
cout<<"\n\n1.  Punjab Male \t "<<ia<<" \t\t Rs 1000 \t Delhi \t Jaipur\n";
cout<<"\n2.  Jan Shatabdi \t "<<sa<<" \t\t Rs 1200 \t Delhi \t Agra\n";
cout<<"\n3.  Shatabdi Express \t "<<isa<<" \t\t Rs 900 \t Agra \t Jaipur\n";
cout<<"\n4.  Exit";
cout<<"\n\n*******************************************************************************" ;

}

void reser:: calculation()
{
first:
cout<<"\nEnter the S.No. from the Menu List\n";
cin>>res.choice[i];
switch(res.choice[i])
{
case 1:
if(ia==0)
{
cout<<"Sorry No Seat avialable";
}
else
{
cout<<"You HAve Choose 1.  Punjab Male From-Delhi To-Jaipur";
ia--;
res.cost[i]=1000 ;
}
break;

case 2:
if(sa==0)
{
cout<<"Sorry No Seat avialable";
}
else
{
cout<<"\nYou HAve Choose \n2.  Jan Shatabdi From-Delhi To-Agra";
sa--;
res.cost[i]=1200;
}
break;

case 3:
if(isa==0)
{
cout<<"\nSorry No Seat avialable";
}
else
{
cout<<"You HAve Choose \n3.  Shatabdi Express From-Agra To-Jaipur";
isa--;
res.cost[i]=900;
}
break;

case 4:
return ;

default:
cout<<"\nWrong Choice\nPlease re-enter Your choice";
getch() ;
goto first;

}

cout<<"\n\nDo u Want to confirm it y/n      ";
char con;
con=getche();
if( con=='n' || con=='N')
{
getch();
if(res.choice[i]==1)
 { ia++; }
if(res.choice[i]==2)
{ sa++;  }
if(choice[i]==3)
{ isa++; }
}

}
void reser:: choicetable()
{
if(res.choice[i]== 1)
{
cout<<"\nPunjab MAle \t Delhi to \t Jaipur\t \n \t\t\tRs 1000 \n";
}
if(res.choice[i]== 2)
{
cout<<"\nJan Shatabdi \t Delhi to \t Agra\t \n \t\t\tRs 1200 \n";
}
if(res.choice[i]== 3)
{
cout<<"\nShatabdi Express \t Agra to \t Jaipur\t \n \t\t\tRs 900 \n";
}
}



void reser:: output()
{
puts(res.nam[i]);
cout<<"\n";
puts(res.add[i]);
res.choicetable();

}

void reser:: total()
{

am=am+res.cost[i];
}

void main()
{
clrscr();
cout<<"\t\t\tRailway Ticket Reservation System\n\n\n\n\n\n";
cout<<"\n\n\tDevelop By-\n \nsourcecodernp.blogspot.com\n";

delay(5000);
clrscr();
gotoxy(22,0);
cout<<"\t\t\t\tLoading Completed";
delay(300);
int l;
int b=219;

 int v1=10, v2=35;
 char lod[10][25]={"CUI",
"Database",
"Opening File",
"Retriving Data",
"Starting notepad",
"Prearing The interface",
"Allocating seats",
"Connecting",
"Connecting With Database",
"Completing",
};
gotoxy(30,30);
 cout<<"\n_______________________________________________________________________________\n";
 cout<<"\t\t\t\tFiles loading";
 cout<<"\n_______________________________________________________________________________\n";

 for(int i=0;i<10;i++)
{
gotoxy(0,0);
      gotoxy(50,1);
      printf("%d  \%",i*10);
gotoxy(0,0);
gotoxy(v1,10);
printf("%c%c",b,b);
printf("%c%c",b,b);
printf("%c%c",b,b);
v1=v1+6;
delay(900);
gotoxy(0,0);
gotoxy(32,v2);

puts(lod[i]);

v2++;
}

       /* for(l=0;l<=10;l++)
{      gotoxy(v,10);
      printf("%c%c%c",b,b,b);
     delay(200);
      v++;
      gotoxy(0,vy);
      puts(pnt[i]);
      delay(200);
      vy++;
      cout<<"\n";
}*/
delay(5000);
clrscr();
cout<<"\n\n\n\n\n\n\nLoading Completed";
delay(2000);
clrscr();
cout<<"\n\n\n\n\nWelcome to The Railway Ticket Reservation System\t\t\n\n Powered By sourcecodernp.blogspot.com";
delay(2000);
clrscr();
start:
cout<<"\nEnter the number of seats u want to book";
gotoxy(35,12);
printf("0=Exit");
gotoxy(4,5);
cout<<"\n";
cin>>rep;
cout<<"\n\n\n\nYou have entered the choice\n %d"<<rep;
clrscr();
if(rep>0 && rep<=10)
{
for(i=0  ; i<rep; i++)
{
cout<<"\nEnter Your Name\t";
fflush(stdin);
gets(res.nam[i]);
cout<<"\nEnter Your Personal Address\t";
gets(res.add[i]);
res.menu();
res.calculation();
if(i<rep-1)
{
cout<<"\n\nPress any key to input next entery";
}
else if(i==rep-1)
{
cout<<"\n\nPress any key to input last  entery";
}
getch();
clrscr();
res.total();
}
for(i=1  ; i<=rep; i++)
{
res.output();
}

cout<<"\nTotal Amount is %f"<<am;

}
else if(rep>10||rep<0)
{
cout<<"You have entered either 0 or negative or greater than 10\n";
goto start;
}
if(rep==0)
 {
  return;
 }
clrscr();
cout<<"Please Wait wile Calculating";
delay(1000);
cout<<".";
delay(1000);
cout<<".";
delay(1000);
cout<<".";
delay(1000);
cout<<".";
delay(2000);
cout<<".";
clrscr();
cout<<"\n\n*******************************************************************************" ;
cout<<"\t\t\t List of Ticket You Have booked\n";
cout<<"\n\n*******************************************************************************\n\n" ;

cout<<"\n\n_________________________________________________________________________________\n\n" ;
for(i=1  ; i<=rep; i++)
{
res.output();
cout<<"\n_________________________________________________________________________________\n\n" ;
}
cout<<"Press any key to calculate sum of amount to be paid";
getch();
clrscr();
cout<<"\nCalculating Your Total Amount to be Paid";
delay(2000);
clrscr();
  cout<<"\nTotal Amount is ";
  cout<<"\n\n\n\n\n\n\t\t\t\tPlease pay \t"<<am;
  float pay, amm;
  cout<<"\n\n\n\t\t";
  getch();
 /* cin>>pay;
  float out;
  out=am-pay;
  while(am!=pay)
  {
if(pay>am)
{
cout<<"PLease Collect the change  "<<(pay-am);
}
if(pay<am)
{
cout<<"Please pay  "<<out<<" amount";
cin>>out;
while((pay-out)!=0)

}
  }   */
clrscr();
  cout<<"\n\n\n\t\tThanks Please wisit Again";
  getch();

}


No comments:

Post a Comment