//employee.h
#include <iostream>
#include <cstring>
using namespace std;
class employee
{
private:
int empno;
char name[20];
double basicSal;
double otHrs;
double otRate;
double allowance;
double totSal;
public:
employee(int pempno, char pname[], double pbasicSal);
void setOtDetails(int potHrs, int potRate);
void setAllowance(int pallowance);
void calcSal();
void printPaySlip();
};
//employee.cpp
#include "employee.h"
employee::employee(int pempno, char pname[], double pbasicSal)
{
empno = pempno;
basicSal = pbasicSal;
strcpy(name,pname);
}
void employee::setOtDetails(int potHrs, int potRate)
{
otHrs = potHrs;
otRate = potRate;
}
void employee::setAllowance(int pallowance)
{
allowance= pallowance;
}
void employee::calcSal()
{
totSal = basicSal + allowance + otHrs*otRate;
}
void employee::printPaySlip()
{
cout << "\n\t\tPay Slip\n";
cout << "\n\tName : \t\t\t" << name << endl
<< "\tEmployee No. :\t\t" << empno << endl;
cout << "\tMonthly allowance :\t" << allowance << endl
<<"\tBasic salery :\t\t" << basicSal << endl
<< "\tTotal OT Hours :\t" << otHrs << endl
<< "\n\tTotal Salery :\t\t" << basicSal << endl << endl;
}
employee::employee(int pempno, char pname[], double pbasicSal)
{
empno = pempno;
basicSal = pbasicSal;
strcpy(name,pname);
}
void employee::setOtDetails(int potHrs, int potRate)
{
otHrs = potHrs;
otRate = potRate;
}
void employee::setAllowance(int pallowance)
{
allowance= pallowance;
}
void employee::calcSal()
{
totSal = basicSal + allowance + otHrs*otRate;
}
void employee::printPaySlip()
{
cout << "\n\t\tPay Slip\n";
cout << "\n\tName : \t\t\t" << name << endl
<< "\tEmployee No. :\t\t" << empno << endl;
cout << "\tMonthly allowance :\t" << allowance << endl
<<"\tBasic salery :\t\t" << basicSal << endl
<< "\tTotal OT Hours :\t" << otHrs << endl
<< "\n\tTotal Salery :\t\t" << basicSal << endl << endl;
}
#include "employee.h"
int main()
{
employee emp1(10, "EJ", 80500);
emp1.setOtDetails(20,100);
emp1.setAllowance(5000);
emp1.calcSal();
emp1.printPaySlip();
return 0;
}
int main()
{
employee emp1(10, "EJ", 80500);
emp1.setOtDetails(20,100);
emp1.setAllowance(5000);
emp1.calcSal();
emp1.printPaySlip();
return 0;
}
0 comments:
Post a Comment