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
No comments:
Post a Comment