#include<conio.h>
#include<iostream.h>
#include<string.h>
#include<stdlib.h>
char ans[20];
int ch,n,a=0,b=0,i,cnt;
class employee
{
protected:int empcode;
char empname[20];
};
class manager:protected employee
{
protected:char desg[20];
int dues;
public:void accept1();
void display1();
}m[10];
void manager::accept1()
{
cout<<"\nenter empcode:-";
cin>>empcode;
cout<<"\nenter empname:-";
cin>>empname;
cout<<"\nenter designation:-";
cin>>desg;
cout<<"\nenter clubdues:-";
cin>>dues;
}
void manager::display1()
{
cout<<empcode<<"\t"
<<empname<<"\t"
<<desg<<"\t"
<<dues<<"\n";
}
class scientist:protected employee
{
protected:char dept[20],pub[20];
public:void accept2();
void display2();
void search(char name[20]);
}s[10];
void scientist::accept2()
{
cout<<"\nenter empcode:-";
cin>>empcode;
cout<<"\nenter empname:-";
cin>>empname;
cout<<"\nenter department name:-";
cin>>dept;
cout<<"\nenter the publication:-";
cin>>pub;
}
void scientist::display2()
{
cout<<empcode<<"\t"
<<empname<<"\t"
<<dept<<"\t"
<<pub<<"\n";
}
void scientist::search(char name[20])
{
int i,cnt;
for(i=0;i<b;i++)
{
cnt=strcmp(name,ans);
if(cnt==0)
cout<<"\nscientist is chemistry department is:-"<<s[i].empname;
}
}
int main()
{
int temp;
clrscr();
while(1)
{
cout<<"\n1:accept the details";
cout<<"\n2:display the information";
cout<<"\n3:to display all the scientist of chemistry department";
cout<<"\n4:exit";
cout<<"\nenter your choice";
cin>>ch;
switch(ch)
{
case 1:cout<<"\nenter how many employee:-";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"\nwhose information you want to enter";
cout<<"\npress 1:for manager";
cout<<"\npress 2:for scientist";
cin>>temp;
if(temp==1)
m[a++].accept1();
else
s[b++].accept2();
}
break;
case 2:for(i=0;i<a;i++)
m[i].display1();
for(i=0;i<b;i++)
s[i].display2();
break;
case 3:strcpy(ans,"chemistry");
s[i].search(ans);
break;
case 4:exit(0);
default:cout<<"\nyou entered wrong choice";
}
}
getch();
return 0;
}
/*
enter your choice1
enter how many employee:-2
whose information you want to enter
press 1:for manager
press 2:for scientist
1
enter empcode:-112
enter empname:-asd
enter designation:-aa
enter clubdues:-75
whose information you want to enter
press 1:for manager
press 2:for scientist
2
enter empcode:-120.
enter empname:-
enter department name:-chemisry
enter the publication:-asd
1:accept the details
2:display the information
3:to display all the scientist of chemistry department
4:exit
enter your choice2
112 asd aa 75
120 . chemisry asd
1:accept the details
2:display the information
3:to display all the scientist of chemistry department
4:exit
enter your choice3
scientist is chemistry department is:-.
1:accept the details
2:display the information
3:to display all the scientist of chemistry department
4:exit
enter your choice4
*/
#include<iostream.h>
#include<string.h>
#include<stdlib.h>
char ans[20];
int ch,n,a=0,b=0,i,cnt;
class employee
{
protected:int empcode;
char empname[20];
};
class manager:protected employee
{
protected:char desg[20];
int dues;
public:void accept1();
void display1();
}m[10];
void manager::accept1()
{
cout<<"\nenter empcode:-";
cin>>empcode;
cout<<"\nenter empname:-";
cin>>empname;
cout<<"\nenter designation:-";
cin>>desg;
cout<<"\nenter clubdues:-";
cin>>dues;
}
void manager::display1()
{
cout<<empcode<<"\t"
<<empname<<"\t"
<<desg<<"\t"
<<dues<<"\n";
}
class scientist:protected employee
{
protected:char dept[20],pub[20];
public:void accept2();
void display2();
void search(char name[20]);
}s[10];
void scientist::accept2()
{
cout<<"\nenter empcode:-";
cin>>empcode;
cout<<"\nenter empname:-";
cin>>empname;
cout<<"\nenter department name:-";
cin>>dept;
cout<<"\nenter the publication:-";
cin>>pub;
}
void scientist::display2()
{
cout<<empcode<<"\t"
<<empname<<"\t"
<<dept<<"\t"
<<pub<<"\n";
}
void scientist::search(char name[20])
{
int i,cnt;
for(i=0;i<b;i++)
{
cnt=strcmp(name,ans);
if(cnt==0)
cout<<"\nscientist is chemistry department is:-"<<s[i].empname;
}
}
int main()
{
int temp;
clrscr();
while(1)
{
cout<<"\n1:accept the details";
cout<<"\n2:display the information";
cout<<"\n3:to display all the scientist of chemistry department";
cout<<"\n4:exit";
cout<<"\nenter your choice";
cin>>ch;
switch(ch)
{
case 1:cout<<"\nenter how many employee:-";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"\nwhose information you want to enter";
cout<<"\npress 1:for manager";
cout<<"\npress 2:for scientist";
cin>>temp;
if(temp==1)
m[a++].accept1();
else
s[b++].accept2();
}
break;
case 2:for(i=0;i<a;i++)
m[i].display1();
for(i=0;i<b;i++)
s[i].display2();
break;
case 3:strcpy(ans,"chemistry");
s[i].search(ans);
break;
case 4:exit(0);
default:cout<<"\nyou entered wrong choice";
}
}
getch();
return 0;
}
/*
enter your choice1
enter how many employee:-2
whose information you want to enter
press 1:for manager
press 2:for scientist
1
enter empcode:-112
enter empname:-asd
enter designation:-aa
enter clubdues:-75
whose information you want to enter
press 1:for manager
press 2:for scientist
2
enter empcode:-120.
enter empname:-
enter department name:-chemisry
enter the publication:-asd
1:accept the details
2:display the information
3:to display all the scientist of chemistry department
4:exit
enter your choice2
112 asd aa 75
120 . chemisry asd
1:accept the details
2:display the information
3:to display all the scientist of chemistry department
4:exit
enter your choice3
scientist is chemistry department is:-.
1:accept the details
2:display the information
3:to display all the scientist of chemistry department
4:exit
enter your choice4
*/
No comments:
Post a Comment