Вы находитесь на странице: 1из 13

//HEADER FILE USED IN PROJECT

#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<string.h>
#include<iomanip.h>
//CLASS USED IN PROJECT
class armoury
{
char arm_no[6];
char arm_name[50];
char arm_lncode[20];
char arm_divuse[20];
char arm_manfct[20];
char arm_type[20];
public:
void create_armoury()
{
cout<<"\n***************NEW ARMAMENT ENTRY***************\n";
cout<<"\nEnter The Armoury no(4-DIGIT)------------->>";
cin>>arm_no;
cout<<"\n\nEnter The Name of The Armoury------------->> ";
gets(arm_name);
cout<<"\n\nEnter The Licensee Code of The Armoury------------->> ";
gets(arm_lncode);
cout<<"\n\nEnter The Manufacturer of The Armoury------------->> ";
gets(arm_manfct);
cout<<"\n\nEnter The type of The Armoury------------->> ";
gets(arm_type);
cout<<"\n\nEnter The Division For Usage(ARMY/IAF/NAVY)------------->> ";
gets(arm_divuse);
cout<<"\n\n\nARMAMENT Created..............";
}
void show_armoury()
{ cout<<"\n\n";
cout<<"========================================================================
========";
cout<<"\n***************ARMOURY NO*************** : "<<arm_no;
cout<<"\n\nName of The Armoury------------->> ";
puts(arm_name);
cout<<"\n\nLicensee Code of The Armoury------------->> ";
puts(arm_lncode);
cout<<"\n\nManufacturer of The Armoury------------->> ";
puts(arm_manfct);
cout<<"\n\ntype of The Armoury------------->> ";
puts(arm_type);
cout<<"\n\nDivision For Usage(ARMY/IAF/NAVY)------------->> ";
puts(arm_divuse);
cout<<"\n\n";
cout<<"========================================================================
========";
}

void modify_armoury()
{
cout<<"\n***************CURRENT ARMOURY NO*************** : "<<arm_no;
cout<<"\n\nModify Armoury Name------------->> ";
gets(arm_name);
cout<<"\n\nModify Licensee Code of The Armoury------------->> ";
gets(arm_lncode);
cout<<"\n\nModify Manufacturer of The Armoury------------->> ";
gets(arm_manfct);
cout<<"\n\nModify type of The Armoury------------->> ";
gets(arm_type);
cout<<"\n\nModify Division For Usage(ARMY/IAF/NAVY)------------->> ";
gets(arm_divuse);
}
char* retarm_no()
{
return arm_no;
}
void report()
{cout<<arm_no<<setw(10)<<arm_name<<setw(12)<<arm_lncode<<setw(14)<<arm_manfct<<s
etw(16)<<arm_type<<setw(18)<<arm_divuse<<endl;}
};
//class ends here
class defence_pers
{
char dpentry_code[6];
char dp_name[20];
char dpdiv[10];
char dp_rank[20];
char dp_branch[10];
char dp_command[10];
char dp_station[20];
char dp_trade[20];
char defparm_no[10];
int token;
public:
void create_defence_pers()
{
clrscr();
cout<<"\n***************NEW DEFENCE PERSONNEL ENTRY*************\n";
cout<<"\n\nEnter The Defence Personnel's Entry Code(5-DIGIT)------------->> ";
cin>>dpentry_code;
cout<<"\nEnter The Name of The Defence Personnel------------->> ";
gets(dp_name);
cout<<"\nEnter The Division of The Defence Personnel(Army/IAF/Navy)------------>> ";
gets(dpdiv);
cout<<"\nEnter The Rank of The Defence Personnel------------->> ";
gets(dp_rank);
cout<<"\nEnter The Branch of The Defence Personnel(tech/NT/FLYING/GROUND)------------>> ";
gets(dp_branch);
cout<<"\nEnter The Command where Defence Personnel POSTED(N/E/W/S)------------->
> ";
gets(dp_command);
cout<<"\nEnter The STATION/BASE/FRONT where Defence Personnel posted------------

->> ";
gets(dp_station);
cout<<"\nEnter The Trade of The Defence Personnel------------->> ";
gets(dp_trade);
token=0;
defparm_no[0]='/0';//TAKING INITIAL POS AS NULL
cout<<"\n\nDefence Personnel Record Created...............";
}
void show_defence_pers()
{ cout<<"\n\n";
cout<<"=========================================================================
=======";
cout<<"\nDefence Personnel Entry code(5-DIGIT)------------->> "<<dpentry_code;
cout<<"\nName of The Defence Personnel------------->> ";
puts(dp_name);
cout<<"\nDivision of The Defence Personnel(Army/IAF/Navy)------------->> ";
puts(dpdiv);
cout<<"\nRank of The Defence Personnel------------->> ";
puts(dp_rank);
cout<<"\nBranch of The Defence Personnel(tech/NT/FLYING/GROUND)------------->> "
;
puts(dp_branch);
cout<<"\nCommand where Defence Personnel POSTED(N/E/W/S)------------->> ";
puts(dp_command);
cout<<"\nSTATION/BASE/FRONT where Defence Personnel posted------------->> ";
puts(dp_station);
cout<<"\nTrade of The Defence Personnel------------->> ";
puts(dp_trade);
cout<<"\nNo of Armament issued------------->> "<<token;
if(token==1)
cout<<"\nIssued armoury No------------->> "<<defparm_no;
cout<<"\n\n";
cout<<"=========================================================================
=======";
}
void modify_defence_pers()
{
cout<<"\n************CURRENT DEFENCE PERSONNEL ENTRY CODE********** : "<<dpent
ry_code;
cout<<"\n\nModify Defence Personnel Name.------------->> ";
gets(dp_name);
cout<<"\nModify Division of The Defence Personnel(Army/IAF/Navy)------------->>
";
gets(dpdiv);
cout<<"\nModify Rank of The Defence Personnel------------->> ";
gets(dp_rank);
cout<<"\nModify Branch of The Defence Personnel(tech/NT/FLYING/GROUND)------------>> ";
gets(dp_branch);
cout<<"\nModify Command where Defence Personnel POSTED(N/E/W/S)------------->>
";
gets(dp_command);
cout<<"\nModify STATION/BASE/FRONT where Defence Personnel posted------------->
> ";
gets(dp_station);
cout<<"\nModify Trade of The Defence Personnel------------->> ";

gets(dp_trade);
}
char* retdpentry_code()
{
return dpentry_code;
}
char* retdefparm_no()
{
return defparm_no;
}
int rettoken()
{
return token;
}
void addtoken()
{token=1;}
void resettoken()
{token=0;}
void getdefparm_no(char t[])
{
strcpy(defparm_no,t);
}
void report()
{cout<<setw(5)<<dpentry_code<<setw(9)<<dp_name<<setw(6)<<dpdiv<<setw(16) <<dp_r
ank<<setw(6)<<dp_branch<<setw(4)<<dp_command<<setw(14)<<dp_station<<setw(8) <<dp
_trade<<setw(4)<<token<<endl;
}
};
//class ends here
//

global declaration for stream object, object

fstream fp,fp1;
armoury arm;
defence_pers defp;
//

function to write in file

void write_armoury()
{
char ch;
fp.open("armoury.dat",ios::out|ios::app);
do
{
clrscr();
arm.create_armoury();
fp.write((char*)&arm,sizeof(armoury));
cout<<"\n\nDo you want to add more ARMOURY record??????????(y/n?)";
cin>>ch;
}
while(ch=='y'||ch=='Y');
fp.close();
}
void write_defence_pers()
{
char ch;
fp.open("defence_pers.dat",ios::out|ios::app);
do

{
defp.create_defence_pers();
fp.write((char*)&defp,sizeof(defence_pers));
cout<<"\n\ndo you want to add more record????????(y/n?)";
cin>>ch;
}
while(ch=='y'||ch=='Y');
fp.close();
}
//

function to read specific record from file

void display_sparm(char n[])


{
cout<<"\n*************ARMOURY DETAILS*************\n";
int flag=0;
fp.open("armoury.dat",ios::in);
while(fp.read((char*)&arm,sizeof(armoury)))
{
if(strcmpi(arm.retarm_no(),n)==0)
{
arm.show_armoury();
flag=1;
}
}
fp.close();
if(flag==0)
cout<<"\n\nArmoury does not exist!!!!!!!!!!!!!";
getch();
}
void display_spdefp(char n[])
{
cout<<"\n*************DEFENCE PERSONNEL DETAILS*************\n";
int flag=0;
fp.open("defence_pers.dat",ios::in);
while(fp.read((char*)&defp,sizeof(defence_pers)))
{
if((strcmpi(defp.retdpentry_code(),n)==0))
{
defp.show_defence_pers();
flag=1;
}
}
fp.close();
if(flag==0)
cout<<"\n\nDefence Personnel does not exist????????????";
getch();
}
//

function to modify record of file

void modify_armoury()
{
char n[6];
int found=0;
clrscr();
cout<<"\n\n\t***************MODIFY ARMOURY RECORD************** ";
cout<<"\n\n\tEnter The armoury no.of armoury to be modified-------------->>";
cin>>n;

fp.open("armoury.dat",ios::in|ios::out);
while(fp.read((char*)&arm,sizeof(armoury)) && found==0)
{
if(strcmpi(arm.retarm_no(),n)==0)
{
arm.show_armoury();
cout<<"\n**********ENTER NEW DETAILS OF ARMOURY*********"<<endl;
arm.modify_armoury();
int pos=-1*sizeof(arm);
fp.seekp(pos,ios::cur);
fp.write((char*)&arm,sizeof(armoury));
cout<<"\n\n\t Record Updated.............";
found=1;
}
}
fp.close();
if(found==0)
cout<<"\n\n Record Not Found?????????????? ";
getch();
}
void modify_defence_pers()
{
char n[6];
int found=0;
clrscr();
cout<<"\n\n\t**************MODIFY DEFENCE PERSONNEL RECORD************* ";
cout<<"\n\n\tEnter Entry Code of defence personnel to be modified----------->>"
;
cin>>n;
fp.open("defence_pers.dat",ios::in|ios::out);
while(fp.read((char*)&defp,sizeof(defence_pers)) && found==0)
{
if(strcmpi(defp.retdpentry_code(),n)==0)
{
defp.show_defence_pers();
cout<<"\n*********ENTER NEW DETAILS OF DEFENCE PERSONNEL*********"<<endl;
defp.modify_defence_pers();
int pos=-1*sizeof(defp);
fp.seekp(pos,ios::cur);
fp.write((char*)&defp,sizeof(defence_pers));
cout<<"\n\n\t Record Updated...............";
found=1;
}
}
fp.close();
if(found==0)
cout<<"\n\n Record Not Found????????? ";
getch();
}
//***************************************************************
//
function to delete record of file
//****************************************************************
void delete_defence_pers()
{
char n[7];
int flag=0;

clrscr();
cout<<"\n\n\n\t***********DELETE DEFENCE PERSONNEL************";
cout<<"\n\nEnter The Entry Code of the Defence Personnel You Want To Delete----------->> \n";
cin>>n;
fp.open("defence_pers.dat",ios::in|ios::out);
fstream fp2;
fp2.open("Temp.dat",ios::out);
fp.seekg(0,ios::beg);
while(fp.read((char*)&defp,sizeof(defence_pers)))
{
if(strcmpi(defp.retdpentry_code(),n)!=0)
fp2.write((char*)&defp,sizeof(defence_pers));
else
flag=1;
}
fp2.close();
fp.close();
remove("defence_pers.dat");
rename("Temp.dat","defence_pers.dat");
if(flag==1)
cout<<"\n\n\tRecord Deleted ................";
else
cout<<"\n\nRecord not found!!!!!!!!!!";
getch();
}
void delete_armoury()
{
char n[6];
int flag=0;
clrscr();
cout<<"\n\n\n\t**************DELETE ARMOURY****************...";
cout<<"\n\nEnter The armoury no. of the armoury You Want To Delete------------>> ";
cin>>n;
fp.open("armoury.dat",ios::in|ios::out);
fstream fp2;
fp2.open("Temp.dat",ios::out);
fp.seekg(0,ios::beg);
while(fp.read((char*)&arm,sizeof(armoury)))
{
if(strcmpi(arm.retarm_no(),n)!=0)
fp2.write((char*)&arm,sizeof(armoury));
else
flag=1;
}
fp2.close();
fp.close();
remove("armoury.dat");
rename("Temp.dat","armoury.dat");
if(flag==1)
cout<<"\n\n\tRecord Deleted ................";
else
cout<<"\n\nRecord not found!!!!!!!!!!";
getch();
}
//

function to display all defence_perss list

void display_alls()
{
clrscr();
fp.open("defence_pers.dat",ios::in);
if(!fp)
{
cout<<"ERROR!!! FILE COULD NOT BE OPEN???????????????? ";
getch();
return;
}
cout<<"\n\n\t****************ALL DEFENCE PERSONNEL LIST****************\n\n";
cout<<"=========================================================================
=======\n";
cout<<"ENTRY CODE.|"<<setw(5)<<"Name|"<<setw(5)<<"DIVISION|"<<setw(5)<<" RANK|"
<<setw(5)<<" BRANCH|"<<setw(5)<<" COMMAND|"<<setw(5)<<" STATION|"<<setw(5)<<"
TRADE|"<<"armoury Issued\n";
cout<<"=========================================================================
=======\n";
while(fp.read((char*)&defp,sizeof(defence_pers)))
{
defp.report();
}
fp.close();
getch();
}
//

function to display armourys list

void display_allb()
{
clrscr();
fp.open("armoury.dat",ios::in);
if(!fp)
{
cout<<"ERROR!!! FILE COULD NOT BE OPEN????????????? ";
getch();
return;
}
cout<<"\n\n\t\t****************ALL armoury LIST****************\n\n";
cout<<"=========================================================================
=======\n";
cout<<"armoury NO."<<setw(5)<<" armoury Name"<<setw(5)<<" ARM LICENSEE CODE
"<<setw(5)<<" MANUFACTURER"<<setw(5)<<" arm type"<<setw(5)<<" DIV USED\n";
cout<<"=========================================================================
=======\n";
while(fp.read((char*)&arm,sizeof(armoury)))
{
arm.report();
}
fp.close();
getch();
}
//

function to issue armoury

void armoury_issue()
{
char dpn[6],armn[6];
int found=0,flag=0;

clrscr();
cout<<"\n\n\t**************ARMOURY ISSUE*************** ";
cout<<"\n\n\Enter The defence_personnel's ENTRY CODE.------------>>";
cin>>dpn;
fp.open("defence_pers.dat",ios::in|ios::out);
fp1.open("armoury.dat",ios::in|ios::out);
while(fp.read((char*)&defp,sizeof(defence_pers)) && found==0)
{
if(strcmpi(defp.retdpentry_code(),dpn)==0)
{
found=1;
if(defp.rettoken()==0)
{
cout<<"\n\n\tEnter the armoury no.------------>> ";
cin>>armn;
while(fp1.read((char*)&arm,sizeof(armoury))&& flag==0)
{
if(strcmpi(arm.retarm_no(),armn)==0)
{
arm.show_armoury();
flag=1;
defp.addtoken();
defp.getdefparm_no(arm.retarm_no());
int pos=-1*sizeof(defp);
fp.seekp(pos,ios::cur);
fp.write((char*)&defp,sizeof(defence_pers));
cout<<"\n\n\t CONGRATULATIONS!!!!!\n\narmoury issued successfully\n\nPlease Not
e: Write the current date\nin backside of your armoury and submit within 50 days
fine Rs. 100 for each day \nafter 50 days period";
}
}
if(flag==0)
cout<<"\narmoury no does not exist!!!!!!!!!!!!";
}
else
cout<<"\nYou have not returned the last armoury!!!!!!!!!!!!";
}
}
if(found==0)
cout<<"\nDefence Personnel record not exist?????????????????????";
getch();
fp.close();
fp1.close();
}
//

function to deposit armoury

void armoury_deposit()
{
char dpn[6],armn[6];
int found=0,flag=0,day;
unsigned short fine;
//range 0-65,535
clrscr();
cout<<"\n\n\t************ARMOURY DEPOSIT************";
cout<<"\n\n\Enter The defence_personnel's ENTRY CODE.----------------->>>>>> ";
cin>>dpn;
fp.open("defence_pers.dat",ios::in|ios::out);
fp1.open("armoury.dat",ios::in|ios::out);
while(fp.read((char*)&defp,sizeof(defence_pers)) && found==0)

{
if(strcmpi(defp.retdpentry_code(),dpn)==0)
{
found=1;
if(defp.rettoken()==1)
{
while(fp1.read((char*)&arm,sizeof(armoury))&& flag==0)
{
if(strcmpi(arm.retarm_no(),defp.retdefparm_no())==0)
{
arm.show_armoury();
flag=1;
cout<<"\n\nEnter armoury deposited in no. of days-------->> ";
cin>>day;
if(day>50)
{
fine=(day-50)*100;
cout<<"\n\nFine has to deposited Rs.-------->> "<<fine;
}
defp.resettoken();
int pos=-1*sizeof(defp);
fp.seekp(pos,ios::cur);
fp.write((char*)&defp,sizeof(defence_pers));
cout<<"\n\n\t armoury deposited successfully";
}
}
if(flag==0)
cout<<"\narmoury no does not exist?????????????????";
}
else
cout<<"\nNo such armoury is issued..please check!!!!!!!!!!!!!";
}
}
if(found==0)
cout<<"\n Defence Personnel record not exist??????????????";
getch();
fp.close();
fp1.close();
}
//

INTRODUCTION FUNCTION

void intro()
{
clrscr();
cout<<"\n";
cout<<"=========================================================================
=======";
cout<<"\n\t_____________________________________________________________________
";
cout<<"\n\n\t
DEFENCE
ARMAMENT
MANAGEMENT
SYSTEM";
cout<<"\n\t_____________________________________________________________________
";
cout<<"\n\n";
gotoxy(18,10);
cout<<" developed by MASTER CALEB PRADHAN & NIKHIL KUMAR \n";
gotoxy(37,12);
cout<<" OF\n";
gotoxy(28,13);

cout<<" CLASS XII-'B'(COMP.SC)\n";


gotoxy(24,14);
cout<<"KENDRIYA VIDYALAYA NO.2 KHARAGPUR\n";
gotoxy(20,16);
cout<<" guided by MRS NANDINI DAS(PGT COMP.SC)\n";
cout<<"\n\n\n===================================================================
=============";
gotoxy(23,23);
cout<<"PRESS ANY KEY TO CONTINUE!!!!!!!!!!!!";
getch();
}
//
DEFENCE ADMINISTRATOR MENU FUNCTION
void admin_menu()
{
clrscr();
int ch2;
cout<<"\n\n\n";
cout<<"========================================================================
========";
cout<<"\n\t...................DEFENCE ADMINISTRATOR MENU..................";
cout<<"\n\n\tPRESS 1 TO CREATE DEFENCE PERSONNEL RECORD----------------";
cout<<"\n\tPRESS 2 TO DISPLAY ALL DEFENCE PERSONNELS RECORD----------";
cout<<"\n\tPRESS 3 TO SEARCH & DISPLAY SPECIFIC DEFENCE PERSONNEL RECORD------- ";
cout<<"\n\tPRESS 4 TO MODIFY SPECIFIC DEFENCE PERSONNEL RECORD-------------";
cout<<"\n\tPRESS 5 TO DELETE SPECIFIC DEFENCE PERSONNEL RECORD-------------";
cout<<"\n\tPRESS 6 TO CREATE ARMOURY-------------- ";
cout<<"\n\tPRESS 7 TO DISPLAY ALL ARMAMENTS------------- ";
cout<<"\n\tPRESS 8 TO SEARCH & DISPLAY SPECIFIC ARMOURY------------- ";
cout<<"\n\tPRESS 9 TO MODIFY ARMAMENT------------ ";
cout<<"\n\tPRESS 10 TO DELETE ARMAMENT------------- ";
cout<<"\n\tPRESS 11 TO GO BACK TO MAIN MENU???????????";
cout<<"\n\n";
cout<<"========================================================================
========";
cout<<"\n\t Please Enter Your Choice (1-11)---------------->>>>> ";
cin>>ch2;
switch(ch2)
{
case 1: clrscr();
write_defence_pers();
break;
case 2: display_alls();
break;
case 3:
char num[6];
clrscr();
cout<<"\n\n\t********SEARCH RECORD OF SPECIFIC DEFENCE PERSONNEL********
*** ";
cout<<"\n\n\tEnter The defence_personnel's ENTRY CODE:------------->> ";
cin>>num;
display_spdefp(num);
break;
case 4: modify_defence_pers();
break;
case 5: delete_defence_pers();
break;
case 6: clrscr();

case
case

case
case
case

write_armoury();
break;
7: display_allb();
break;
8: {
char num[6];
clrscr();
cout<<"\n\n\t********SEARCH RECORD OF SPECIFIC ARMOURY*********** ";
cout<<"\n\n\tPlease Enter The armoury No.------------->> ";
cin>>num;
display_sparm(num);
break;
}
9: modify_armoury();
break;
10: delete_armoury();
break;
11: return;
default:cout<<"\a";

}
admin_menu();
}

//

THE MAIN FUNCTION OF PROGRAM

void main()
{
char ch;
intro();
do
{
clrscr();
cout<<"\n";
cout<<"========================================================================
========";
cout<<"\n\n\n\t\t\tM A I N
M E N U";
cout<<"\n\n\n\tPRESS 1 FOR ARMOURY ISSUE............";
cout<<"\n\n\tPRESS 2 FOR ARMOURY DEPOSIT............";
cout<<"\n\n\tPRESS 3 FOR DEFENCE ADMINISTRATOR MENU.........";
cout<<"\n\n\tPRESS 4 FOR EXITING............";
cout<<"\n\n\n";
cout<<"========================================================================
========";
cout<<"\n\n\tPlease Select Your Option (1-4)-------------->> ";
ch=getche();
switch(ch)
{
case '1':clrscr();
armoury_issue();
break;
case '2':armoury_deposit();
break;
case '3':admin_menu();
break;
case '4':exit(0);
default :cout<<"\a";

}
}while(ch!='4');
}
//

END OF PROJECT

Вам также может понравиться