#include<conio.h>
#include<iostream.h>
#include<string.h>
#include<stdlib.h>
class employee
{
public:int empcode;
char name[20];
};
class fulltime:public employee
{
protected:int dr,nod,sal;
public:void accept();
void display();
}f[10];
void fulltime::accept()
{
cout<<"\nenter empcode:-";
cin>>empcode;
cout<<"\nenter name:-";
cin>>name;
cout<<"\nenter daily rate:-";
cin>>dr;
cout<<"\nenter no of days:-";
cin>>nod;
sal=nod*dr;
}
void fulltime::display()
{
cout<<empcode<<"\t"
<<name<<"\t"
<<dr<<"\t"
<<nod<<"\t"
<<sal<<"\n";
}
class parttime:public employee
{
protected:int nowh,hr,sal;
public:void accept();
void display();
}p[10];
void parttime::accept()
{
cout<<"\nenter empcode:-";
cin>>empcode;
cout<<"\nenter name:-";
cin>>name;
cout<<"\nenter hourly rate:-";
cin>>hr;
cout<<"\nenter no of hours worked:-";
cin>>nowh;
sal=nowh*hr;
}
void parttime::display()
{
cout<<empcode<<"\t"
<<name<<"\t"
<<hr<<"\t"
<<nowh<<"\t"
<<sal<<"\n";
}
int main()
{
int a=0,b=0,n,i,ch,cnt1,cnt2,temp;
char ans[20];
clrscr();
while(1)
{
cout<<"\n1:accept details of n employee";
cout<<"\n2:display details of n employee";
cout<<"\n3:search a given employee";
cout<<"\n4:exit";
cout<<"\nenter your choice:-";
cin>>ch;
switch(ch)
{
case 1:cout<<"\nhow many employee:-";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"\npress 1: to fill records of part time employee";
cout<<"\npress 2: to fill records of full time employee\n";
cin>>temp;
if(temp==1)
f[a++].accept();
else
p[b++].accept();
}
break;
case 2:cout<<"\ndetails of all employee\n";
cout<<"\nempcode name\tdailyrate numberofdays salary\n";
for(i=0;i<a;i++)
f[i].display();
cout<<"\nempcode name\tno.ofhout hourlyrate salary\n";
for(i=0;i<b;i++)
p[i].display();
break;
case 3:cout<<"\nenter employee name which you want to search:-";
cin>>ans;
for(i=0;i<a;i++)
{
cnt1=strcmp(f[i].name,ans);
if(cnt1==0)
break;
}
for(i=0;i<b;i++)
{
cnt2=strcmp(p[i].name,ans);
if(cnt2==0)
break;
}
if(cnt1==0||cnt2==0)
cout<<"\nyes the given employee is present in the record";
else
cout<<"\nno the given employee is not present in the record";
break;
case 4:exit(0);
default:cout<<"\nyou enter wrong choice";
}
}
getch();
return 0;
}
#include<iostream.h>
#include<string.h>
#include<stdlib.h>
class employee
{
public:int empcode;
char name[20];
};
class fulltime:public employee
{
protected:int dr,nod,sal;
public:void accept();
void display();
}f[10];
void fulltime::accept()
{
cout<<"\nenter empcode:-";
cin>>empcode;
cout<<"\nenter name:-";
cin>>name;
cout<<"\nenter daily rate:-";
cin>>dr;
cout<<"\nenter no of days:-";
cin>>nod;
sal=nod*dr;
}
void fulltime::display()
{
cout<<empcode<<"\t"
<<name<<"\t"
<<dr<<"\t"
<<nod<<"\t"
<<sal<<"\n";
}
class parttime:public employee
{
protected:int nowh,hr,sal;
public:void accept();
void display();
}p[10];
void parttime::accept()
{
cout<<"\nenter empcode:-";
cin>>empcode;
cout<<"\nenter name:-";
cin>>name;
cout<<"\nenter hourly rate:-";
cin>>hr;
cout<<"\nenter no of hours worked:-";
cin>>nowh;
sal=nowh*hr;
}
void parttime::display()
{
cout<<empcode<<"\t"
<<name<<"\t"
<<hr<<"\t"
<<nowh<<"\t"
<<sal<<"\n";
}
int main()
{
int a=0,b=0,n,i,ch,cnt1,cnt2,temp;
char ans[20];
clrscr();
while(1)
{
cout<<"\n1:accept details of n employee";
cout<<"\n2:display details of n employee";
cout<<"\n3:search a given employee";
cout<<"\n4:exit";
cout<<"\nenter your choice:-";
cin>>ch;
switch(ch)
{
case 1:cout<<"\nhow many employee:-";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"\npress 1: to fill records of part time employee";
cout<<"\npress 2: to fill records of full time employee\n";
cin>>temp;
if(temp==1)
f[a++].accept();
else
p[b++].accept();
}
break;
case 2:cout<<"\ndetails of all employee\n";
cout<<"\nempcode name\tdailyrate numberofdays salary\n";
for(i=0;i<a;i++)
f[i].display();
cout<<"\nempcode name\tno.ofhout hourlyrate salary\n";
for(i=0;i<b;i++)
p[i].display();
break;
case 3:cout<<"\nenter employee name which you want to search:-";
cin>>ans;
for(i=0;i<a;i++)
{
cnt1=strcmp(f[i].name,ans);
if(cnt1==0)
break;
}
for(i=0;i<b;i++)
{
cnt2=strcmp(p[i].name,ans);
if(cnt2==0)
break;
}
if(cnt1==0||cnt2==0)
cout<<"\nyes the given employee is present in the record";
else
cout<<"\nno the given employee is not present in the record";
break;
case 4:exit(0);
default:cout<<"\nyou enter wrong choice";
}
}
getch();
return 0;
}
No comments:
Post a Comment