Академический Документы
Профессиональный Документы
Культура Документы
A Project On “Police
Management System In
C++”
Submitted By :- Shubhadra Kumari (SCOB70)
Tushar Kulwade (SCOB83)
Tejas Badgujar(SCOB73).
As per the proposed system, we have the switch case in the login
page. Here we provided five options to the customer: to
purchase, to see menu, to edit, to exit and to see objective.
1)To purchase: It will ask to see the menu using if else
condition. To place order the customer have to enter the item
code and the quantity to buy it. Customer can buy the various
items. Finally the bill will generate.
2)To see menu: The file “item” will open and the contents will
read out. Then the file will close.
3)To edit: It will ask to add or to remove the food items.
a) To add: It will ask to how many no of items toad. The file
will open and the contents will added. Later the file will
close.
b) To remove: It will ask to enter the item code to remove
from file. The file will open, another temporary file will
open. The data will copy from file to temporary file except
the removing the item one. The file will remove and the
temporary fill will rename to original one. Then file will
close.
4) To exit: Uses the exit function.
5)To see objective: Shows the moto of the project.
Modules:
Here, we use the concept of single inheritance and file
handling.
Conclusion:
Source Code:
/* Police Station Management System using C++ and compiled using GCC
Compiler */
#include<iostream>
#include<conio.h>
#include<ctype.h>
#include<direct.h>
#include<process.h>
#include<windows.h>
#include<string.h>
#include<stdio.h>
#include<fstream>
#include<string.h>
#include<stdlib.h>
#include<iomanip>
#include<time.h>
/* Defining functions */
struct date
{
int d;
int m;
int y;
};
struct court
{
char crime[20];
char act[20];
char cour[20];
char state[20];
};
struct descp
{
char colour[20];
char face[20];
char imark[20];
char height[6];
char eye_color[20];
};
struct police
{
char station[50];
char fir_no[10];
date date_arrest;
};
int login()
{
char username[30];
char password[30];
int true1 = 1;
int try1 = 0;
int i=0;
do
{
system("cls");
cout << "\n\n\n\n\n\n";
cout <<"\t\t\t\t ----------------------------------\n";
cout <<"\t\t\t\t |POLICE STATION MANAGEMENT SYSTEM|\n";
cout <<"\t\t\t\t ----------------------------------\n";
cout <<"\n\n";
cout << "\t\t\t\t\t";
cout << "Username : ";
cin >> username;
cout << "\t\t\t\t\t";
cout << "\n";
cout << "\t\t\t\t\t";
cout << "Password : ";
cin >> password;
if(strcmp(username,"admin")==0 && strcmp(password,"pass")==0)
{
cout << "\n\n";
cout << "\t\t\t\t";
cout << "You are accessed to the system!\n\n";
cout << "\t\t\t\t";
system("pause");
system("cls");
true1 = 0;
return 1;
}
else
{
system("cls");
try1 = try1+1;
cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
cout << "\t\t\t\t\t";
cout << "No. of attempts remain: " << 3-try1;
cout << "\n\n";
cout << "\t\t\t\t";
system("pause");
if(try1>=3)
{
void mainpage()
{
int process=0;
system("cls");
date1();
cout << "\n";
cout <<"\t\t\t\t ----------------------------------\n";
cout <<"\t\t\t\t |POLICE STATION MANAGEMENT SYSTEM|\n";
cout <<"\t\t\t\t ----------------------------------\n";
cout <<"\n\n";
cout <<"\t\t\t\t";
cout <<"Prepared By ";
cout <<":";
cout <<" Chetan Khunti";
cout <<"\n\n";
cout <<"\t\t\t\t";
cout <<"Mini Project ";
cout <<":";
cout <<" Police Station Management System";
cout <<"\n\n";
cout <<"\t\t\t\t";
cout <<"\n\n";
cout <<"\n\n";
cout <<"\t\t\t\t";
system("pause");
cout <<"\n\t\t\t\tLoading";
for(process=0;process<25;process++)
{
delay(150);
cout <<".";
}
}
void callExit()
{
int process = 0;
system("cls");
cout << "\n\n\n\n\n";
cout << "\n\tTaking You Out of The System";
for(process=0;process<25;process++)
{
delay(150);
cout <<".";
}
system("cls");
cout <<"\n\n\n\n\n\n\n\n\n\n\n";
cout <<"\t\t\t\t\t";
cout <<"You are out of the System.\n";
cout <<"\t\t\t\t\t\t";
cout << "Thank You !";
cout <<"\n\n";
cout <<"\t\t\t\t\t";
system("pause");
exit(0);
}
void date1()
{
time_t T= time(NULL);
struct tm tm = *localtime(&T);
cout << "\n\n\n";
cout << "\t\t\t\t\t Date:" << tm.tm_mday << "/" << tm.tm_mon+1 <<
"/" << tm.tm_year+1900 << "\n";
}
class criminal
{
private:
char name[20];
char sex[3];
char conno[10];
char age[4];
char address[50];
court COURT;
police POLICE;
descp des;
public:
int ncheck(char arr[]); // function to check that
input is non-numeric
int s_check(char a[]); // function to check sex has
only 1 character "M" or "F"
void input(void); // function to take input
void output(void); // function for displaying
output
void delete_rec(char con_no[]); // function to delete a
record
int dcheck(char n[]); // function to search
convict id in file
void display(); // function to display all
records
void remove(); // function to remove an
entry
void modify(); // function to modify
existing records
void list(); // function to list all
records
void empty(); // function to enter new
record while modifying
int concheck(char b[]); // function to check convict
ID
};
void menu(criminal l)
{
int input;
while(true)
{
system("cls");
cout << "\n\n\n";
cout << "\t\t\t\t\t";
cout << "\n";
cout << "\t\t\t\t ----------------------------------\n";
cout << "\t\t\t\t |POLICE STATION MANAGEMENT SYSTEM|\n";
cout << "\t\t\t\t ----------------------------------\n";
cout << "\n\n\n\n";
cout << "\t\t\t\t";
cout << " 1. ADD RECORD\n\n";
cout << "\t\t\t\t";
cout << " 2. MODIFY RECORD\n\n" ;
cout << "\t\t\t\t" ;
cout << " 3. DISPLAY RECORD\n\n" ;
cout << "\t\t\t\t" ;
cout << " 4. DELETE RECORD\n\n" ;
cout << "\t\t\t\t" ;
cout << " 5. LIST ALL RECORDS\n\n" ;
cout << "\t\t\t\t" ;
cout << " 6. EXIT\n\n" ;
cout << "\t\t\t\t" ;
cout << "Choose Option:[1/2/3/4/5/6] : " ;
fflush(stdin);
cin >> input;
switch(input)
{
case 1:
{
l.input();
break;
}
case 2 :
{
l.modify();
break;
}
case 3:
{
l.display();
break;
}
case 4:
{
l.remove() ;
break;
}
case 5:
{
l.list();
break;
}
case 6:
{
callExit();
}
break;
default:
{
cout << "\n\n\n" ;
cout << "\t\t\t\t" ;
cout << " Invalid input!" ;
cout << "\n\n" ;
cout << "\t\t\t\t" ;
fflush(stdin);
getchar();
menu(l);
}
}
}
}
i++;
continue;
}
else
{
cout << "\n\tIncorrect input. Try again !\n ";
return 0;
}
}
return 1;
}
{
system("cls");
this->empty();
criminal x;
int c = 0 ;
fflush(stdin);
fstream filin;
filin.open("jail.txt",ios::app);
while(c != 1)
{
cout << "\n\n\n\tENTER THE CONVICT ID : ";
cin >> (this->conno);
c = x.concheck(this->conno);
fflush(stdin);
}
c = 0;
cout <<"\n\n ENTER THE CONVICT DETAILS\n";
while(c != 1)
{
cout << "\n" << setw(10) <<"\tNAME : ";
cin >> (this->name);
c = ncheck(this->name);
}
fflush(stdin);
c = 0;
while(c != 1)
{
cout << "\n" << setw(10) << "\tSEX : ";
cin >> (this->sex);
c = s_check(this->sex);
}
fflush(stdin);
cout << "\n" << setw(10) << "\tADDRESS : ";
cin >> (this->address);
fflush(stdin);
cout << "\n" << setw(10) << "\tAGE : ";
cin >> (this->age);
fflush(stdin);
cout << "\n\tIDENTIFICATION MARKS : ";
cin >> (this->des.imark);
fflush(stdin);
cout << "\n\tEYE COLOUR : ";
cin >> (this->des.eye_color);
system("cls");
while(!c)
{
cout << "\n\t\t\t\t\t Year(4 digits) : ";
cin >> this->POLICE.date_arrest.y;
if((this->POLICE.date_arrest.y <= 1930)||(this-
>POLICE.date_arrest.y>2017))
{
cout << "\n\t\tINCORRECT INPUT, TRY AGAIN!!\n";
c = 0;
}
else
c = 1;
}
char ch;
do
{
cout << "\n\tDO YOU WANT TO SAVE THIS INFORMATION(Y/N) : ";
cin >> ch;
if(ch=='y'||ch=='Y')
{
cout << "\n\n\t< RECORD HAS BEEN SAVED >";
filin.write((char*)this,sizeof(criminal));
}
else
{
if((ch!='n')&&(ch!='N'))
{
cout<<"\n\t\tENTER CORRECTLY \n\t\t TRY AGAIN !!\n\n";
}
}
}
while((ch!='y') && (ch!='Y') && (ch!='n') && (ch!='N'));
filin.close();
cout << "\n\n\t\t";
system("pause");
system("cls");
cout << "\n\n\t\t----------CRIMINAL RECORD----------";
cout << "\n\n\t\t\tCOURT INFORMATION\n\n ";
cout << "\n\t1. COURT OF CONVICTION :\t";
puts(this->COURT.cour);
cout << "\n\t2. STATE :\t";
puts(this->COURT.state);
cout << "\n\t3. CRIME :\t";
puts(this->COURT.crime);
cout << "\n\t4. ACT :\t";
puts(this->COURT.act);
cout << "\n\n\n\t\t\t";
system("pause");
system("cls");
system("cls");
int x = 0, count = 0, c;
int q = file.tellg();
c = q/sizeof(criminal);
file.close();
file.open("jail.txt",ios::in|ios::binary);
for(int i=0;i<c;i++)
{
file.read((char*)this,sizeof(criminal));
count++;
if(strcmp(n,conno)==0)
{
x++;
break;
}
}
if(x==0)
{
cout<<"\n\n\n\n\tCONVICT NOT FOUND!! ";
getchar();
return 0;
}
else
{
return count;
}
file.close();
}
void criminal::remove()
{
fflush(stdin);
system("cls");
char no[10];
int s;
cout << "\n\n\n\t\tENTER THE CONVICT ID : ";
gets(no);
s = this->dcheck(no);
if(s!=0)
this->delete_rec(no);
}
while(c != 1)
{
cout<<"\n\t\t\t\t\t Year(in 4 digits) : ";
cin >> D.y;
if((D.y <= 1930)||(D.y>2017) )
{
cout << "\n\t\tINCORRECT INPUT, TRY AGAIN!!\n";
c = 0;
}
else
c = 1;
}
POLICE.date_arrest.d=D.d;
POLICE.date_arrest.m=D.m;
POLICE.date_arrest.y=D.y;
loc = (check-1)*sizeof(criminal);
file.seekp(loc);
file.write((char*)this,sizeof(criminal));
file.close();
cout <<"\n";
fflush(stdin);
cout << "\n\n\t\t\t < RECORD MODIFIED >";
}
else
{
cout << "\n\n\n\t\tPRESS 'Y' TO TRY AGAIN 'N' TO GO TO QUIT : ";
char ch_m;
cin >> ch_m;
fflush(stdin);
if(ch_m == 'y' || ch_m == 'Y')
{
system("cls");
goto modify_start;
}
else
{
callExit();
}
}
}
cout<<"\n=============================================================
===================\n";
cout<<"SR.\tNAME\t\t\tCONVICT NO.\t\t\tCRIME\n";
cout<<"===============================================================
=================\n";
int i = 0;
while(file.read((char*)this,sizeof(criminal)))
{
i++;
cout << i << " ";
for(j=0; j<strlen(this->name); j++)
cout << this->name[j];
cout<<"\t\t\t ";
for(j=0; j<strlen(this->conno); j++)
cout << this->conno[j];
cout << "\t\t\t ";
for(j=0; j<strlen(this->COURT.crime); j++)
cout << this->COURT.crime[j];
cout <<"\n";
fflush(stdin);
getchar();
cout << "\n-------------------------------------------------------
-------------------------\n";
if((i%3)==0&&(i!=c))
{
system("pause");
system("cls");
cout <<
"\n===================================================================
=============\n";
cout << "SR.\tNAME\t\t\tCONVICT NO.\t\t\tCRIME\n";
cout <<
"=====================================================================
===========\n";
}
}
file.close();
getchar();
}
void criminal::empty()
{
int i;
for(i=0; i<20; i++)
name[i]=' ';
for(i=0; i<10; i++)
conno[i]=' ';
for(i=0; i<3; i++)
sex[i]=' ';
for(i=0; i<4; i++)
age[i]=' ';
for(i=0; i<50; i++)
address[i]=' ';
for(i=0; i<20; i++)
COURT.cour[i]=' ';
for(i=0; i<20; i++)
COURT.crime[i]=' ';
for(i=0; i<20; i++)
COURT.act[i]=' ';
for(i=0; i<20; i++)
COURT.state[i]=' ';
for(i=0; i<20; i++)
des.colour[i]=' ';
for(i=0; i<20; i++)
des.imark[i]=' ';
for(i=0; i<20; i++)
des.face[i]=' ';
for(i=0; i<6; i++)
des.height[i]=' ';
for(i=0; i<15; i++)
des.eye_color[i]=' ';
for(i=0; i<50; i++)
POLICE.station[i]=' ';
for(i=0; i<10; i++)
POLICE.fir_no[i]=' ';
POLICE.date_arrest.m = 0;
POLICE.date_arrest.d = 0;
POLICE.date_arrest.y = 0;
}
int main()
{
system("cls");
mainpage();
criminal l;
int x,res=1;
res = login();
if(res == 1)
{
menu(l);
}
}
Output: