Professional Documents
Culture Documents
class EMP
Begin
protected:
char name[20],add[50],edu[50],cnic[50], city[15]
char ph[15],cell[15]
float salary,ded,tax,net,leave
int id
public:
friend ostream& operator<<(ostream & Read, EMP &h)
EMP(float a=0, float x=0, float y=15,float z=0,float l=0, int m=0)
Begin
salary=a
ded=x
tax=y/100
net=z
leave=l
id=m
int i=0
while(i<19)
Begin
name[i]=' '
i++
End-while
name[i]=NULL
i=0
while(i<49)
Begin
add[i]=' '
edu[i]=' '
cnic[i]= ' '
i++
End-while
add[i]=edu[i]=cnic[i]=NULL
i=0
while(i<15)
Begin
city[i]=' '
ph[i]=' '
cell[i]=' '
i++
End-while
city[i]=ph[i]=cell[i]=NULL
End-Empl
void setsalary(float rate, float thr)
Begin
salary=rate*thr
End
void setded(float a)
Begin
ded=a
End
void settax(float a=15)
Begin
tax=a/100
End
void setnet(float rate,float bonus, float allowance)
Begin
float temp=0
temp=salary+bonus+allowance-ded
salary=temp
if(salary<0)
Begin
salary=0
End-if
net=temp-(temp*tax)
if(net<0)
Begin
net=0
End-if
End
void setname(char x[])
Begin
int i=0
while(x[i]!=NULL)
Begin
name[i]=x[i]
i++
End-while
name[i]=NULL
End
void setleave(float l)
Begin
leave=l
End
void setid(int a)
Begin id=a End
float getsalary()
Begin
return salary
End
float getded()
Begin
return ded
End
float gettax()
Begin
tax=salary*tax
return tax
End
float getnet()
Begin
return net
End
float getleave()
Begin
return leave
End
char* getname()
Begin
return name
End
char* getadd()
Begin
return add
End
char* getedu()
Begin
return edu
End
int getid()
Begin
return id
End
char* getcnic()
Begin
return cnic
End
End
class Date
Begin
private:
int day,month,year
public:
Date(int a=0, int b=0, int c=0)
Begin
day=a
month=b
year=c
End
void setday(int a)
Begin
if(a<=0)
Begin
a=1
End-if
if(a>31)
Begin
a=31
End-if
day=a
End
void setmonth(int a)
Begin
if(a<=0)
Begin
a=1
End-if
if(a>31)
Begin
a=31
End-if
month=a
End
void setyear(int a)
Begin
year=a
End
int getday()
Begin
return day
End
int getmonth()
Begin
return month
End
int getyear()
Begin
return year
End
friend istream &operator >>(istream & Read, Date &a)
friend ostream &operator <<(ostream & Read, Date &d)
End
public:
/////////////// CONSTRUCTOR ////////////////////
HOURLY(float a=0, float b=0,float c=0, float d=0)
Begin
rate=a
tothr=b
allowance=c
bonus=d
int i=0
while(i<19)
Begin
contract[i]=post[i]=' '
i++
contract[i]=post[i]=NULL
End-while
End
void setrate(float a)
Begin rate=a End
void settothr(float a)
Begin tothr=a End
void setallowance(float a)
Begin allowance=a End
void setbonus(float a)
Begin bonus=a End
void setdate()
Begin
Read d
End
void setcalc()
Begin
int x=20,y=15,c=38
while(y<33)
Begin
Display ::
y=y+2
End-while
Display ID #
Display Name
Display Post
Display Rate / Hour
Display Total Work Hours
Display Total Allowance
Display Extra Time Bonus
Display Deduction Amount
Display Total Leaves
char temp[20]
Displaygetid()
Displaygetname()
Displaypost
Displayrate
gets (temp) settothr(atof(temp))
gets (temp) setallowance(atof(temp))
gets (temp) setbonus(atof(temp))
gets (temp) setded(atof(temp))
gets (temp) setleave(atof(temp))
setsalary(rate,tothr) setnet(rate,bonus,allowance)
End
void getcalc()
Begin
int x=20,y=15,c=38
while(y<35)
Begin
(c,y) Display ::
y=y+2
End-while
Display ID #
Display Name
Display Post
Display Rate / Hour
Display Total Work Hours
Display Extras
Display Deduction Amount
Display salary
Display Tax Deducted
Display Net Salary
Displaygetid()
Displaygetname()
Displaypost
Displayrate
Displaygettothr()
printf( %0.0f , getallowance()+getbonus())
printf( %0.0f ,getded())
printf( %0.0f , getsalary())
printf( %0.0f ,gettax())
printf( %0.0f ,getnet())
End
void setwdays(float a)
Begin
if(days<=0||days>31)
Begin wdays=0 End-if
else
Begin
wdays=a
End-else
End
End
void setallowance(float a)
Begin allowance=a End
void setbonus(float a)
Begin bonus=a End
void setbasic(float a)
Begin basic=a End
void setdate()
Begin
Read d
End
///////////////// GETTERS ////////////////////
void getdate()
Begin Displayd End
float getwdays()
Begin return wdays End
float getdays()
Begin return days End
float getallowance()
Begin return allowance End
float getbonus()
Begin return bonus End
float getbasicc()
Begin return basic End
void setnetsalary()
Begin
int x=20,y=15,c=38
while(y<35)
Begin
(c,y) Display ::
y=y+2
End-while
Display ID #
Display Name
Display Post
Display Basic Salary
Display Salary for Month(1-12)
Display Days Work
Display Total Allowance
Display Commission / Bonus
Display Deduction Amount
Display Total Leaves
char temp[20]
Displaygetid()
Displaygetname()
Displaypost
Displaybasic
gets (temp) setdays(atof(temp))
gets (temp) setwdays(atof(temp))
gets (temp) setallowance(atof(temp))
gets (temp) setbonus(atof(temp))
gets (temp) setded(atof(temp))
gets (temp) setleave(atof(temp))
setsalary(basic/days,wdays) setnet(basic,bonus,allowance)
End
void getnetsalary()
Begin
int x=20,y=15,c=38
while(y<35)
Begin
(c,y) Display ::
y=y+2
End-while
Display ID #
Display Name
Display Post
Display Basic Salary
Display Total Work Days
Display Extras
Display Deduction Amount
Display salary
Display Tax Deducted
Display Net Salary
Displaygetid()
Displaygetname()
Displaypost
Displaybasic
Displaygetwdays()
printf( %0.0f , getallowance()+getbonus())
printf( %0.0f ,getded())
printf( %0.0f ,getsalary())
printf( %0.0f ,gettax())
printf( %0.0f ,getnet())
End
i=0
while(i<4)
Begin
ch[i]=getche()
i++
ch[i]='\0'
End-while
a.setyear(atoi(ch))
End
ostream &operator<<(ostream & Read, Date &d)
Begin
Displayd.getday()<< / <<d.getmonth()<< / <<d.getyear()
End
///////////// GLOBAL FUNCTION DETAIL PRINT HOURLY CLASS ////////////////////
void detail (void)
Begin
int x=20,y=15,c=35
while(y<35)
Begin
(c,y) Display ::
y=y+2
End-while
Display ID #
Display Name
Display Post
Display Qualification
Display Address
Display City
Display Phone
Display Mobile
Display Rate/Hour
Display Joining Date
End
Display ID #
Display Name
Display Post
Display Qualification
Display Address
Display City
Display Phone
Display Mobile
Display Basic Salary
Display Joining Date
End
mdetail()
Displayh.getid()
puts(h.name)
puts(h.post)
puts(h.add)
puts(h.edu)
puts(h.city)
puts(h.ph)
puts(h.cell)
Displayh.basic
h.getdate()
return Read
End
detail()
Displayh.getid()
puts(h.name)
puts(h.post)
puts(h.add)
puts(h.edu)
puts(h.city)
puts(h.ph)
puts(h.cell)
Displayh.rate
h.getdate()
return Read
End
while(exit==0)
Begin
n=selection()
if (n=='1')
Begin
newentry(p,m)
End-if
if (n=='2')
Begin
setsalary(p,m)
End-if
if (n=='3')
Begin
list(p,m)
End-if
if (n=='4')
Begin
getsalary(p,m)
End-if
if (n=='5')
Begin
modify(p,m)
End-if
if (n=='6')
Begin
delentry(p,m)
End-if
if (n=='7')
Begin
exit=exit+1
End-if
End-while
entry()
End
char n
printf ( M A I N M E N U )
while(exit==0)
Begin
n=new_selection()
if (n=='1')
Begin
staffentry(p)
End-if
if (n=='2')
Begin
mstaffentry(m)
End-if
if (n=='3')
Begin
exit=exit+1
End-if
End-while
End
/////////////// DELETE STAFF ENTRY //////////////////////////
while(exit==0)
Begin
n=new_selection()
if (n=='1')
Begin
hdelentry(p)
End-if
if (n=='2')
Begin
mdelentry(m)
End-if
if (n=='3')
Begin
exit=exit+1
End-if
End-while
End
while(exit==0)
Begin
n=new_selection()
if (n=='1')
Begin
staffmodify(p)
End-if
if (n=='2')
Begin
mstaffmodify(m)
End-if
if (n=='3')
Begin
exit=exit+1
End-if
End-while
End
if (n=='1')
Begin
stafflist(p)
End-if
if (n=='2')
Begin
mstafflist(m)
End-if
if (n=='3')
Begin
exit=exit+1
End-if
End-while
End
char new_selection()
Begin
char n
printf ( S T A F F E N T R Y )
while(exit==0)
Begin
n=new_selection()
if (n=='1')
Begin
setcalc(p)
End-if
if (n=='2')
Begin
msetcalc(m)
End-if
if (n=='3')
Begin
exit=exit+1
End-if
End-while
End
if (n=='1')
Begin
getcalc(p)
End-if
if (n=='2')
Begin
mgetcalc(m)
End-if
if (n=='3')
Begin
exit=exit+1
End-if
End-while
End
void mstaffentry(MONTHLY m)
Begin
Display S T A F F M O D I F Y
Display TOTAL RECORDS :
Displayj
Display gets(temp) search=atoi(temp)
ifstream in( emp.dat ,ios::binary)
if(search<=j)
Begin
while(in.read((char*)&p,sizeof(p)))
Begin
if(r==0)
Begin
if(search!=p.getid())
Begin
out.write((char*)&p,sizeof(p))
End-if
else
Begin
r++
End-else
End-while
else
Begin
if(search!=p.getid())
Begin
p.setid(p.getid()-1)
out.write((char*)&p,sizeof(p))
End-if
End-else
End-while
remove ( emp.dat )
rename( temp.dat , emp.dat )
End-if
Display S T A F F L I S T
Display TOTAL RECORDS :
Displayit
Displayp
Display Continue Listing Items Press Y.......
Display Return To Main Menu Press N.......
choice=getche()
End-if
End-while
End-if
else
Begin
Display S T A F F L I S T
Display TOTAL RECORDS :
Displayit
Display SORRY NO RECORD FOUND
Display PRESS ANY KEY TO RETURN .......
getch()
End-else
End
///////////////// MONTHLY STAFF LIST ////////////////////////
void mstafflist(MONTHLY m)
Begin
int j=0,x,y,it=0
char choice='y'
it=mvalue(m)
ifstream in( month.dat ,ios::binary|ios::app)
if(j<it)
Begin
while(in.read((char *)&m,sizeof(m)))
Begin
if(choice=='y' || choice=='Y')
Begin
Display S T A F F L I S T
Display TOTAL RECORDS :
Displayit
Display m
Display Continue Listing Items Press Y.......
Display Return To Main Menu Press N.......
choice=getche()
End-if
End-while
End-if
else
Begin
Display S T A F F L I S T
Display TOTAL RECORDS :
Displayit
Display SORRY NO RECORD FOUND
Display PRESS ANY KEY TO RETURN .......
getch()
End-else
End
///////////////////////////////// SALARY ENTRIES
HOURLY //////////////////////////////
void setcalc(HOURLY p)
Begin
char con,temp[15],n[2]
int x,y,j,sno con='y'
ofstream out( temp.dat ,ios::app|ios::binary)
int i=value(p) j=0
if(j<i)
Begin
Display S A L A R Y F O R M
Display Enter The SERIAL NO
Display TOTAL RECORDS
Displayi
Display n[0]=getche() n[1]=NULL
sno=atoi(n)
ifstream in( emp.dat ,ios::binary)
while(in.read((char*)&p,sizeof(p)))
Begin
if(sno==p.getid())
Begin
Display S A L A R Y E N T R Y
Display TOTAL RECORDS
Displayi
p.setcalc()
out.write((char*)&p,sizeof(p))
Display Return To Main Menu Press Any Key.......
con=getche()
End-if
else
Begin
out.write((char*)&p,sizeof(p))
End-else
End-while
remove( emp.dat )
rename( temp.dat , emp.dat )
j=j+1
End-if
else
Begin
nosearch(i)
End-else
End
///////////////////////////////// SALARY ENTRIES
MONTHLY //////////////////////////////
void msetcalc(MONTHLY m)
Begin
char con,temp[15],n[2]
int x,y,j,sno con='y'
ofstream out( temp.dat ,ios::app|ios::binary)
int i=mvalue(m) j=0
if(j<i)
Begin
Display S A L A R Y F O R M
Display Enter The SERIAL NO
Display TOTAL RECORDS :
Displayi
Display n[0]=getche() n[1]=NULL
sno=atoi(n)
ifstream in( month.dat ,ios::binary)
while(in.read((char*)&m,sizeof(m)))
Begin
if(sno==m.getid())
Begin
Display S A L A R Y E N T R Y
Display TOTAL RECORDS
Displayi
m.setnetsalary()
out.write((char*)&m,sizeof(m))
Display Return To Main Menu Press Any Key.......
con=getche()
End-if
else
Begin
out.write((char*)&m,sizeof(m))
End-else
End-while
remove( month.dat )
rename( temp.dat , month.dat )
j=j+1
End-if
else
Begin
nosearch(i)
End-else
End
/////////////////////// GET ENTERIES SALARY
HOURLY ////////////////////////////////
void getcalc(HOURLY p)
Begin
int j=0,x,y,it=0
char choice='y'
it=value(p)
ifstream in( emp.dat ,ios::binary|ios::app)
if(j<it)
Begin
while(in.read((char *)&p,sizeof(p)))
Begin
if(choice=='y' || choice=='Y')
Begin
Display S A L A R Y D I S P L A Y
Display TOTAL RECORDS :
Displayit
p.getcalc()
Display Continue Listing Items Press Y.......
Display Return To Main Menu Press N.......
choice=getche()
End-if
End-while
End-if
else
Begin
Display S A L A R Y D I S P L A Y
Display TOTAL RECORDS :
Display it
Display SORRY NO RECORD FOUND
Display PRESS ANY KEY TO RETURN .......
getch()
End-else
End
/////////////////////// GET ENTERIES SALARY
MONTHLY ////////////////////////////////
void mgetcalc(MONTHLY m)
Begin
int j=0,x,y,it=0
char choice='y'
x=20 y=15
it=mvalue(m)
ifstream in( month.dat ,ios::binary|ios::app)
if(j<it)
Begin
while(in.read((char *)&m,sizeof(m)))
Begin
if(choice=='y' || choice=='Y')
Begin
Display S A L A R Y D I S P L A Y
Display TOTAL RECORDS
Displayit
m.getnetsalary()
Display Continue Listing Items Press Y.......
Display Return To Main Menu Press N.......
choice=getche()
End-if
End-while
End-if
else
Begin
Display S A L A R Y D I S P L A Y
Display TOTAL RECORDS :
Display it
Display SORRY NO RECORD FOUND
Display PRESS ANY KEY TO RETURN .......
getch()
End-else
End
///////////////////////// no search //////////////////////////////
void nosearch (int i)
Begin
Display S E A R C H
Display TOTAL RECORDS
Display i
Display SORRY NO RECORD FOUND
Display PRESS ANY KEY TO RETURN .......
getch()
End
////////////////////// HOURLY VALUE ////////////////////////
int value (HOURLY e)
Begin
int j=0
ifstream in( emp.dat ,ios::binary)
while(in.read((char*)&e,sizeof(e)))
Begin
j=j+1
End-while
return j
End
//////////////////// MONTHLY VALUE ///////////////////////////