Solution of Exercise 6 in rough format but is working...
Bari Mushkil say bana hay...
Code:
#include <iostream>
#include<conio.h>
using namespace std;
char ch;
class employee
{
private:
enum etype{laborer,secretary,manager,accountant,executive,researcher};
etype x;
int employeeno;
float compensation;
class date
{
private:
int day,month,year;
public:
void getdate(int count)
{
cout<<"enter "<<count<<" Date : ";
cin>>day>>ch>>month>>ch>>year;
}
void showdate()
{
cout<<day<<ch<<month<<ch<<year<<endl;
}
};
public:
date var;
void putemploy()
{
static count=1;
cout<<"Enter Employ "<<count<<" Number";
cin>>employeeno;
cout<<"Enter "<<count<<" Compensation";
cin>>compensation;
var.getdate(count);
cout<<"enter "<<count<<" Employee Type";
count++;
switch(getch())
{
case 'l': x=laborer ; break;
case 's': x=secretary ; break;
case 'm': x=manager ; break;
case 'a': x=accountant; break;
case 'e': x=executive ; break;
case 'r': x=researcher;
}
cout<<endl;
}
void getemploy()
{
cout<<"Employ No :"<<employeeno<<endl;
cout<<"Employ Compensation : "<<compensation<<endl;
cout<<"Employ Date : ";
var.showdate();
cout<<"Employ Type: ";
switch(x){
case 0: cout<<"laborer\n" ; break;
case 1: cout<<"secretary\n" ; break;
case 2: cout<<"manager\n" ; break;
case 3: cout<<"accountant\n"; break;
case 4: cout<<"executive\n" ; break;
case 5: cout<<"researcher\n"; break;
default: cout<<"Undefined\n";}}
};
void main()
{
employee x[3];
for(int i=0; i<3;i++){
x[i].putemploy();
}
for(int j=0; j<3; j++)
{
x[j].getemploy();
}
}