C++ Source Codes

TICKET MANAGEMENT SYSTEM

(MY OWN PROJECT 100% Accurate)



#include<iostream.h>

#include<string.h>
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<iomanip.h>
#include<stdlib.h>
#include<graphics.h>
#include<ctype.h>

/***********************************
Group members (1)Hafiz Aliahsan (2) Rana Shahid Iqbal(3) Muhammad Ramzan (4)Luqman Doaggar
(5) Arsaln Javed 
********************************************/


/****************************
PASSENGER CLASS
*****************************/

class passenger
{
int id;
char name[50];
char fname[50];
int age;
char city[50];
int seatno;
char contact[25];
int amount;
public:

/*
passenger()
{
id=0;
} */




void getdata(); //function to get data from user
void showdata();//function to show data on screen
int getid() const;



};





void passenger::getdata()
   {

id++;



cout<<"\n\t\t\tYOUR ID IS THIS-:"<<id;
A:
cout<<"\n\tEnter the Passenger Name:-";
gets(name);
for(int i=0;i<=5;i++)
{
if(name[i]=='\b')
{
i=i+1;
}
if(!(isalpha(name[i])))
{

goto A;
}

}

B:
cout<<"\n\tEnter the Father Name:-";
gets(fname);
for( i=0;i<=5;i++)
{
if(fname[i]=='\b')
{
i=i+1;
}
if(!(isalpha(fname[i])))
{

goto B;
}

}
C:
cout<<"\n\tTravel From Lhr To:-";
gets(city);
for( i=0;i<=5;i++)
{
if(name[i]=='\b')
{
i=i+1;
}
if(!(isalpha(city[i])))
{

goto C;
}

}









cout<<"\n\tEnter the seat no:-";
cin>>seatno;
while(!cin)
{
cin.clear();
cin.ignore();
cout<<"\nInvalid seat no:\nPlz Enter Valid Seat No:-";
cin>>seatno;
}
cout<<"\n\tPlz Enter the Age:-";
cin>>age;
while(!cin)
{
cin.clear();
cin.ignore();
cout<<"\n\tYou have enter invalid age\n\tPLz Enter The Valid Age:-";
cin>>age;
}
if (age>1&&age<=100)
{
cout<<"\n";
}
else
{
cout<<"\nInvalid age enter\nPlz Enter The Valid Age :-";
cin>>age;
}
cout<<"\n\tEnter The Contact Number:-";
cin>>contact;
while(!cin)
{
cin.clear();
cin.ignore();
cin>>contact;
}
while(strlen(contact)>11||strlen(contact)<11)
{
cout<<"\n\tInvalid contactnumber\n\tEnetr valid number -:";
cin>>contact;
}


cout<<"\n\tEnter The Ticket Amount:-";
cin>>amount;
while(!cin)
{
cin.clear();
cin.ignore();
cout<<"\nEnter Amount is Invalid\nEnter The Valid Amount:-";
cin>>amount;
}


}

void passenger::showdata()
{


cout<<"\nID= "<<id;
cout<<"\nPassenger Name :- "<<name;
cout<<"\n Passenger Father Name is:- "<<fname;
cout<<"\n Passenger City is:- "<<city;
cout<<"\n The Seat No  is :- "<<seatno;
cout<<"\n Passenger Age is :- "<<age;
cout<<"\n Passenger Cell No Is :- "<<contact;
cout<<"\nAmount is this:- "<<amount;

}


int passenger::getid()const
{
return id;
}
























int   main()
{
int gdriver=DETECT,gmod;
initgraph(&gdriver,&gmod,"");

clrscr();
setbkcolor(4);


passenger p;
fstream file;
file.open("C:\\p.dat",ios::ate|ios::out | ios::in | ios::app | ios::binary);
char ch,nm[20],ID;
int choice,found=0;
  do

  {
    setcolor(4);
settextstyle(4,0,5);
settextjustify(LEFT_TEXT,RIGHT_TEXT);
outtextxy(40,3,"Ticket Management System");

settextstyle(7,0,3);
settextjustify(LEFT_TEXT,RIGHT_TEXT);
outtextxy(145,80,"1:-For New Passenger");
settextstyle(7,0,3);
settextjustify(LEFT_TEXT,RIGHT_TEXT);

outtextxy(145,110,"2:-Display All Passenger");
outtextxy(145,140,"3:-Search By Ticket ID");

  /* outtextxy(145,170,"4:-Search By Name Passenger"); */
outtextxy(145,170,"4:-Delete Ticket");
outtextxy(145,200,"5:-Exit");





     /*
cout<<"\n\n\n\n\n\t\t\t01. FOR NEW PASSENGER";
cout<<"\n\n\t\t\t02. DISPLAY ALL LIST";
cout<<"\n\n\t\t\t03. SEARCH BY PASSENGER,S TICKET";
cout<<"\n\n\t\t\t04. SEARCH BY  PASSENGER NAME";
cout<<"\n\n\t\t\t05. CANCEL PASSENGER TICKET";
cout<<"\n\n\t\t\t06. EXIT";    */
      rectangle(40,65,550,300);

 cout<<"\n\n\n\t\t\tSelect Your Option (1-6) ";
cin>>choice;
switch(choice)
{

case 1:
     cleardevice();
p.getdata();
cin.get(ch);

file.write((char *) &p,size of(passenger));
file.close();
cleardevice();

break;
case 2:
    //  passernger p;
      // ifstream file;
 cleardevice();

    file.seekg(0,ios::cur);
cout<<"\nDISPLAY LIST";




      while(file.eof())
      {
      while( file.read((char *) (&p),sizeof(passenger)));
      {


p.showdata();


}
}
file.close();


getch();
cleardevice();
break;

case 3:
cleardevice();
int n;
cout<<"\nPLz Enter The Ticket ID-:";
cin>>n;
if(!file)
{
}
  while( file.read((char *) (&p),sizeof(passenger)));
  {
  if(p.getid()==n)
  {
  p.show data();
  }
  }
  file.close();
  getch();
  break;





default:exit(0);
}


 clrscr();

}while(1);


 closegraph();
    getch();
}
Try This Code  your own compiler
BEST OF LUCK!!!!

____________________________________________

what is Input Validation

The Process In which We put the validation in any software 
By Input Validation Mean Put the limitations in any software or programm

Why We Use Input Validation

By Using Input validation our programm or software can make valueable Bcz By using Validation In Software the Software give or take the accurates values or things
For Examples 
We Make the  Student Management System Software in which we put the name age class date of birth :etc,
Input validation mean programm accept only value or data type in which we give 
For  Example :
we Take int id then programm accept only integer type :
If we give character for id then Programm Not Accept this Data

(With out input validation)

char name ;

int birth;

We entered the name: 45
we entered the birth date :Ali 

(With Input Validation)

Int birth;

char name;

int age;

cout<<"Plz Enter the Name ";

cin>>name;

while(!cin)

{

cout<<"Plz Enter the Name";

cin>>name;

}

cout<<"Plz Enter the Age " ;

cin>>age;

if(age>1&&age<=100)

{

}

else

cout<<"Plz Enter the Age";

cin>>age;

if(age>1&&age<=100)

{

cout<<"Age correct";

}


Complete Example of Input Validation In C++

#include<conio.h>

#include<iostream.h>

 void main()

{

int id;

char name;

int age;

cout<<"Plz Enter the Id";

cin>>id;

while(!cin)

{

cout<<"Plz Enter the ID";

cin>> id;

}

cout<<"Plz Enter The name ";

cin>>name;

while(!cin)

{

cout<<"Plz Enter the Correct Name";

cin>>name;

}

cout<<"Plz Enter the Age";

cin>age;

if(age>0&&age<=100)

{

cout<<"Plz Enter The Age";

cin>>age;

}

getch();

}

(Let,s Try on Your Own Compiler)

Good Luck !!!


Validation of Mobile Number

we can do the validation of mobile number by using string length comparison

In Some Software's Number validation is must bcz when users entered the Mobile Number.           It can me wrong ,it can be short and it can also lengthy ( After getting the applicant number if need to contact the person the contact address may be short number may be long 

Therefore In some software's Validation Of Contact number Is Compulsory 

It Is the key of validation of Mobile Number


   while(strlen(contact)>11||strlen(contact)<11)

complete Example of Contact No Validation

#include<conio.h>
#include<iostream.h>
main()
{
char contact [25];
cout<<"\n\tEnter The Contact Number:-";
cin>>contact;
while(!cin)
{
cin.clear();
cin.ignore();
cin>>contact;
}
while(strlen(contact)>11||strlen(contact)<11)
{
cout<<"\n\tInvalid contactnumber\n\tEnetr valid number -:";
cin>>contact;
         getch();
}


Validation of  NIC NUMBER


For Example (issuing of Sim ) (For Job Application) ;etc
Same case here as in Contact number validation
   while(strlen(nic)>13||strlen(nic)<13)


complete Example of Nic No Validation
#include<iostream.h>
main()
{
char nic [25];
cout<<"\n\tEnter The Nic Number:-";
cin>>nic;
while(!cin)
{
cin.clear();
cin.ignore();
cin>>nic;
}
while(strlen(nic)>13||strlen(contact)<13)
{
 cout<<"\n\tInvalid  Nic number\n\tEnetr valid number -:";
 cin>>nic;
         getch();
 }

Let,s Try on your own Compiler Best of luck !!!








 




No comments:

Post a Comment