Doc.

Employee Program.pdf


Code

employee.h

class employee{ 
private:
    int id;
    float WorkingHours;
    float HourRate;
public:
    employee();
    employee(int i, float wh, float hr);
    void SetData(int i, float wh, float hr);
    float BasicSalary();
    float OverTime();
    float Taxes();
    float NetSalary();
    void Print();
};

employee.cpp

#include "employee.h"
#include <iostream>
using namespace std;

employee::employee()
{
    id =0;
    WorkingHours =0;
    HourRate =0;
}

employee::employee(int i, float wh, float hr)
{
    id =i;
    WorkingHours =wh;
    HourRate =hr;
}

void employee::SetData(int i, float wh, float hr)
{
    id =i;
    WorkingHours =wh;
    HourRate =hr;
}

float employee::BasicSalary()
{
    if(WorkingHours>=40)
    return 40* HourRate; else
    return WorkingHours * HourRate;
}

float employee::OverTime()
{
    if(WorkingHours>40)
    return (WorkingHours-40)* HourRate *1.5 ; else return 0;
}

float employee::Taxes()
{
    float salary;
    salary = BasicSalary()+ OverTime();

    if (salary >=0 && salary <= 1000)
        return 0;
    else if( salary >1000 && salary <= 2000)
        return salary * 0.05;
    else
        return salary * 0.1;
}

float employee::NetSalary()
{
    return BasicSalary()+ OverTime() - Taxes();
}

void employee::Print()
{
    cout << "Id : " << id << endl;
    cout << "Salary : " << BasicSalary() << endl;
    cout << "Over Time : " << OverTime() << endl;
    cout << "Taxes : " << Taxes() << endl;
    cout << "Net Salary : " << NetSalary()
}

main.cpp

# include <iostream>
# include "employee.h"
using namespace std;

void main()
{
    employee e1;
    employee e2(10, 10, 40);
    
    e1.SetData(7,30,40);
    
    e1.Print();
    e2.Print();
    
    cout << "The salary of the employee 1 = " << e1.NetSalary() << endl;
    cout << "The salary of the employee 2 = " << e2.NetSalary() << endl;
    system("pause");
}