-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathques7.cpp
More file actions
79 lines (60 loc) · 2.06 KB
/
ques7.cpp
File metadata and controls
79 lines (60 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "ques7.h"
#include <string>
#include <iostream>
using namespace std;
//accessor functions
double Employee::getBasicSalary()
{
return basicSalary;
}
double Employee::getPension()
{
return pension;
}
double Employee::getMedicalAid()
{
return medicalAid;
}
float Employee::getTaxPercentage()
{
return taxPercentage;
}
//function to calculate the amount deducted from salary for tax
double Employee::calcTax(double grossPay, double deductions, Employee employee)
{
float taxP = employee.getTaxPercentage();
double taxAmount = taxP*(grossPay-deductions);
return taxAmount;
}
//function to calculate gross pay
double Employee::calcGrossPay(Employee employee)
{
//get the values
double theBasicSalary = employee.getBasicSalary();
double thePension = employee.getPension();
double theMed= employee.getMedicalAid();
//calculate gross salary
double grossPay = theBasicSalary+thePension+theMed;
return grossPay;
}
//function to calculate how much should be deducted from the gross salary for pension and medical aid
double Employee::calcDeductions(Employee employee)
{
double thePension = employee.getPension();
double theMed= employee.getMedicalAid();
double deductions = (theMed*2) + (thePension*2);
return deductions;
}
//overloaded extraction operator that can be used to input values of type Employee into the object
istream& operator>>(istream& sendIn, Employee& employee)
{
cout << "\nEnter the basic salary: ";
sendIn >> employee.basicSalary;
cout << "\nEnter the pension amount that the employee pays: ";
sendIn >> employee.pension;
cout << "\nEnter the medical aid amount that the employee pays: ";
sendIn >> employee.medicalAid;
cout << "\nEnter the tax percentage: ";
sendIn >> employee.taxPercentage;
return sendIn;
}