Sie sind auf Seite 1von 8

#include<fstream.

h>
#include<conio.h>
#include<process.h>
#include<string.h>
class employee
{
private:
char emp_name[20];
char emp_code[5];
char desig[5];
char h_name[20];
char street[20];
char city[20];
char sex;
float HRA;
float DA;
float CCA;
float FCA;
float PF;
int basic;
float salary;
public:
void get();
void hra();
void da();
void cca();
void fca();
void disp();
void calculate();
void total_p();
void basic_da();
void display();
void pay_slip();
char* getempcode()
{
return(emp_code);
}
employee() //constructor
{
emp_code[0]='\0';
emp_name[0]='\0';
desig[0]='\0';
h_name[0]='\0';
street[0]='\0';
city[0]='\0';
sex='\0';
HRA=0.0;
DA=0.0;
CCA=0.0;
FCA=0.0;
PF=0.0;
basic=0;
salary=0.0;
}
~employee() //destructor
{

}
};
void employee::calculate()
{
clrscr();
int no,day,ch;
cout<<"\n LEAVE MONITORING :"
;
cout<<"\nEnter type of leave :";
cout<<"\n 1.Casual";
cout<<"\n 2. Sick";
cout<<"\n 3. Previlage";
cout<<"\n 4. Illegal";
cout<<"\nEnter type of leave:";
cin>>ch;
cout<<"\nEnter no. of days of leave:";
cin>>no;
switch(ch)
{
case 1: if(no>12)
day=no-12;
salary=salary-((basic/30)*day);
break;
case 2: if(no>14)
day=no-14;
salary=salary-((basic/30)*day);
break;
case 3: if(no>12)
day=no-12;
salary=salary-((basic/30)*day);
break;
case 4: if(no!=0)
day=no;
salary=salary-((basic/30)*day);
break;
default: cout<<"\nSorry Invalid type."
}
clrscr();
}
void employee::display()
{
cout<<"\n\n EMPLOYEE NAME : "<<emp_name;
cout<<"\n\n EMPLOYEE CODE : "<<emp_code;
cout<<"\n\n DESIGNATION
: "<<desig;
cout<<"\n\n ADDRESS
\n";
cout<<"---------------------- "<<endl;
cout<<"\n
"<<h_name;
cout<<"\n
"<<street;
cout<<"\n
"<<city;
cout<<"\n\n SEX : "<<sex;
getch();
}
void employee::pay_slip()
{
calculate();
clrscr();

cout<<"
CADBURY'S INDIA LIMITED \n\n ";
cout<<endl;
cout<<"\n\n****************************************************\n\n
";
cout<<" \n\n
PAY SLIP
\n\n
";
cout<<endl;
cout<<"\n\n****************************************************\n\n
";
cout<<"\n\n
cout<<"\n\n
cout<<"\n\n
cout<<"\n\n
cout<<"\n\n
cout<<"\n\n
cout<<"\n\n
cout<<"\n\n
cout<<"\n\n
getch();

EMPLOYEE
EMPLOYEE
SALARY
BASIC
HRA
DA
CCA
FCA
PF

NAME : "<<emp_name;
CODE : "<<emp_code;
: "<<salary;
: "<<basic;
: "<<salary*HRA/100;
: "<<salary*DA/100;
: "<<salary*CCA/100;
: "<<salary*FCA/100;
: "<<PF;

}
void employee::get()
{
char ch;
cout<<"\n\n ENTER THE EMPLOYEE NAME : ";
cin>>emp_name;
int flag=0;
do
{
cout<<"\n\n ENTER THE EMPLOYEE CODE : " ;
cin>>emp_code;
if ((emp_code[0]!='E')||(strlen(emp_code)>5))
{
clrscr();
cout<<"\nINVALID DATA "<<endl;
cout<<"----------------------\n";
cout<<"* ENTER THE EMPLOYEE CODE STARTING WITH
`E'"<<endl;
cout<<"* EMPLOYEE CODE MUST NOT EXCEED FIVE CHARACTERS
"<<endl;
cout<<"\nENTER THE CODE AGAIN \n";
}
else
flag=1;
}while(flag==0);
do
{
cout<<"\n ENTER THE DESIGNATION OF EMPLOYEE"<<endl;
cout<<" ------------------------------------"<<endl;
cout<<"\n AAO ";
cout<<"\n BM ";
cout<<"\n ADM ";
cout<<"\n DM ";
cout<<"\n ZM ";
cout<<"\n ADO ";
cout<<"\n DO ";
cout<<"\n TYP ";
cout<<"\n LTF ";

cout<<"\n PEON ";


cout<<"\n--------------------------------------"<<endl;
cout<<"\n\n DESIGNATION :";
cin>>desig;
cin.get(ch);
if
((strcmp(desig,"AAO")==0)||(strcmp(desig,"BM")==0)||(strcmp(desig,"ADM")=
=0)||
(strcmp(desig,"DM")==0)||(strcmp(desig,"ZM")==0)||(strcmp(desig,"AD
O")==0)||
(strcmp(desig,"DO")==0)||(strcmp(desig,"TYP")==0)||(strcmp(desig,"L
TF")==0)||(strcmp(desig,"PEON")==0))
{
flag=0;
cout<<"\n VALID DATA "<<endl;
basic_da();
hra();
da();
cca();
total_p();
fca();
}
else
{
clrscr();
cout<<"INVALID DATA........ENTER AGAIN \n" ;
continue;
}
}while(flag==1);
cout<<"\n\n ENTER THE ADDRESS \n";
cout<<"---------------------- "<<endl;
cout<<"\n HOUSE NAME : ";
cin>>h_name;
cout<<"\n STREET : ";
cin>>street;
cout<<"\n CITY : ";
cin>>city;
cout<<"\nENTER THE SEX OF THE EMPLOYEE (M/F) : ";
cin>>sex;
cin.get(ch);
}
void employee::basic_da()
{
if((strcmp(desig,"AAO")==0))
basic=2100;
else
if((strcmp(desig,"BM")==0))
basic=2940;
else
if((strcmp(desig,"ADM")==0))
basic=4520;
else
if((strcmp(desig,"ZM")==0))

basic=5350;
else
if((strcmp(desig,"ADO")==0))
basic=1225;
else
if((strcmp(desig,"DO")==0))
basic=1350;
else
basic=950;
}
void employee::hra()
//FUNCTION TO CALCULATE HRA
{
HRA=(.20*(basic));
}
void employee::da()
//FUNCTION TO CALCULATE DA
{
if(basic<2500)
DA=(.0067*(basic));
else
if(basic>2500 && basic<4000)
DA=((.0067*2500)+(.0055*(basic-2500)));
else
DA=((.0067*2500)+(.0055*1500)+(.0033*2600)+(.17*(basic-4260)));
}
void employee::cca() //TO CALCULATE CCA
{
if
((strcmp(city,"BOMBAY")==0)||(strcmp(city,"KOLKATA")==0)||(strcmp(city,"M
ADRAS")==0))
{
CCA=(.15*(basic));
}
else
{
CCA=0.0;
}
}
void employee::fca()
{
if((strcmp(desig,"ADD")==0))
{
FCA=350.0;
}
else
if ((strcmp(desig,"DO")==0))
{
FCA=450.0;
}
else
if ((strcmp(desig,"BM")==0))
{
FCA=600.0;
}
else
{
FCA=0.0;
}

}
void employee::total_p()
{
PF=(.10*basic);
salary+=(HRA+DA+FCA+CCA+basic)-PF;
}
void display()
{
clrscr();
int flag=1;
employee emp;
char ecode[5];
cout<<"\n
EMPLOYEE CODE:
";
cin>>ecode;
clrscr();
ifstream infile;
infile.open("employs.dat",ios::binary|ios::in);
if(!infile)
{
cout<<"@@@@FILE NOT FOUND@@@@\n";
getch();
exit(0);
}
while(infile)
{
infile.read((char*)&(emp),sizeof(emp));
if(strcmp(ecode,emp.getempcode())==0)
{
emp.display();
flag=0;
break;
}
}
clrscr();
if(flag==1)
cout<<"No such employee record found in the file\n";

}
void pay_slip()
{
clrscr();
int flag=1;
employee emp;
char ecode[5];
cout<<"\n
EMPLOYEE CODE:
";
cin>>ecode;
clrscr();
ifstream infile;
infile.open("employs.dat",ios::binary|ios::in);
if(!infile)
{
cout<<"@@@@FILE NOT FOUND@@@@\n";
getch();

exit(0);
}
while(infile)
{
infile.read((char*)&(emp),sizeof(emp));
if(strcmp(ecode,emp.getempcode())==0)
{
emp.pay_slip();
flag=0;
break;
}
}
clrscr();
if(flag==1)
cout<<"No such employee record found in the file\n";

}
int main()
{
clrscr();
int ch;
employee obj;
int i=0;
cout<<"\n MAIN MENU \n";
while(ch!=4)
{
clrscr();
cout<<"\n1.ADD RECORDS ";
cout<<"\n2.SEE EMPLOY PAYSLIP" ;
cout<<"\n3.DISPLAY EMPLOYEE RECORD" ;
cout<<"\n4.QUIT\n---------------------------------";
cout<<"\n ENTER YOUR CHOICE :" ;
cin>>ch;
if(ch==1)
{
char choice;
ofstream infile;
infile.open("employs.dat",ios::binary|ios::app|ios::out);
do
{
cout<<"\t\t ENTER THE RECORD "<<++i;
obj.get();
infile.write((char*)&obj,sizeof(obj));
cout<<"Do you want to continue(y/n)? ";
cin>>choice;
}while(choice=='y');
infile.close();
}
else
else
else
else

if(ch==2) pay_slip();
if(ch==3) display();
if(ch==4) return 0;
cout<<"\n#####Invalid Choice######\n";

}
getch();
return 0;
}

Das könnte Ihnen auch gefallen