Write a program to create salary sheet using virtual..
#include<iostream.h>
#include<conio.h>
class worker
{
public:
char name[50];
void putname()
{
cout<<"\n Enter the name of worker: ";
cin>>name;
}
void getname()
{
cout<<"\n Name of Worker = "<<name;
}
};
class money : virtual public worker
{
public:
long salary;
void putsal()
{
cout<<"\n Enter the basic salary: ";
cin>>salary;
}
void getsal()
{
cout<<"\n Basic salary = "<<salary;
}
};
class deduction : virtual public money
{
public:
long pf,me;
void putex()
{
cout<<"\n Enter the provident fund: ";
cin>>pf;
cout<<"\n Enter the medical expence: ";
cin>>me;
}
void getex()
{
cout<<"\n Provident Fund= "<<pf;
cout<<"\n Medical Expence= "<<me;
}
};
class total: public deduction
{
public:
long td;
void getded()
{
td=pf+me;
cout<<"\n Total Deduction = "<<td;
}
};
class pagar : public total
{
public:
long mss;
void getpg()
{
mss=salary-td;
cout<<"\n Monthly Salary = "<<mss;
}
};
class result : public pagar
{
public:
long ys;
void pr()
{
ys=mss*12;
cout<<"\n Yearly salary = "<<ys;
}
};
void main()
{
clrscr();
result d;
d.putname();
d.putsal();
d.putex();
d.getname();
d.getex();
d.getded();
d.getpg();
d.pr();
getch();
}
#include<conio.h>
class worker
{
public:
char name[50];
void putname()
{
cout<<"\n Enter the name of worker: ";
cin>>name;
}
void getname()
{
cout<<"\n Name of Worker = "<<name;
}
};
class money : virtual public worker
{
public:
long salary;
void putsal()
{
cout<<"\n Enter the basic salary: ";
cin>>salary;
}
void getsal()
{
cout<<"\n Basic salary = "<<salary;
}
};
class deduction : virtual public money
{
public:
long pf,me;
void putex()
{
cout<<"\n Enter the provident fund: ";
cin>>pf;
cout<<"\n Enter the medical expence: ";
cin>>me;
}
void getex()
{
cout<<"\n Provident Fund= "<<pf;
cout<<"\n Medical Expence= "<<me;
}
};
class total: public deduction
{
public:
long td;
void getded()
{
td=pf+me;
cout<<"\n Total Deduction = "<<td;
}
};
class pagar : public total
{
public:
long mss;
void getpg()
{
mss=salary-td;
cout<<"\n Monthly Salary = "<<mss;
}
};
class result : public pagar
{
public:
long ys;
void pr()
{
ys=mss*12;
cout<<"\n Yearly salary = "<<ys;
}
};
void main()
{
clrscr();
result d;
d.putname();
d.putsal();
d.putex();
d.getname();
d.getex();
d.getded();
d.getpg();
d.pr();
getch();
}
No comments:
Post a Comment