-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtester.cpp
More file actions
111 lines (78 loc) · 2.93 KB
/
tester.cpp
File metadata and controls
111 lines (78 loc) · 2.93 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
using namespace std;
#include "newSeven.h"
#include <string>
#include <iostream>
#include <cstdlib>
using namespace std;
class Manager : public Employee
{
public:
//default constructor
Manager();
//overloaded constructor
Manager(double theSalary, double thePension, double theMedicalAid, float theTaxPercentage, double theAllowance);
//function to display salary details
void Display();
//function to get entertainment allowance amount
double getAllowance();
//overridden function to calculate the tax
double calcTax(double grossPay, double deductions, double allowance);
//overridden function to calculate the gross pay
double calcGrossPay();
private:
//entertainment allowance
double Allowance;
};
//overloaded constrcutor
Manager::Manager(double theSalary, double thePension, double theMedicalAid, float theTaxPercentage, double theAllowance):Employee(theSalary, thePension, theMedicalAid, theTaxPercentage)
{
Allowance = theAllowance;
}
//accessor for entertainment allowance
double Manager::getAllowance()
{
return Allowance;
}
//function to display salary details
void Manager::Display()
{
cout<<"\nThe details of the manager's salary are the following: ";
cout << "basic salary: R" << getBasicSalary() << endl;
cout << "pension amount: R" << getPension() << endl;
cout << "medical aid amount: R" << getMedicalAid() << endl;
cout << "Allowance: R" << Allowance << endl;
cout << "% tax paid: " << getTaxPercentage();
}
double Manager::calcTax(double grossPay, double deductions, double allowance)
{
float taxP = getTaxPercentage();
double taxAmount = taxP*(grossPay-deductions);
return taxAmount;
}
//function to calculate gross pay
double Manager::calcGrossPay()
{
//get the values
double theBasicSalary = getBasicSalary();
double thePension = getPension();
double theMed= getMedicalAid();
double theAllowance = getAllowance();
//calculate gross salary
double grossPay = theBasicSalary+thePension+theMed+theAllowance;
return grossPay;
}
int main()
{
//instantiate an object of type Manager
Manager manager(60560, 5500, 2800, 0.14, 3100);
manager.Display();
double currentGrossPay = manager.calcGrossPay();
cout <<endl<<"Current gross pay: "<<currentGrossPay;
double currentDeductions = manager.Employee::calcDeductions(manager);
cout<<"\nDeductions: "<<currentDeductions;
double currentAllowance = manager.getAllowance();
double currentTaxAmount = manager.calcTax(currentGrossPay, currentDeductions, currentAllowance);
cout<<endl<<"tax: "<<currentTaxAmount;
double netSalary = currentGrossPay - currentTaxAmount - currentDeductions;
cout <<"\nNetSalary after medical aid, pension and tax has been paid: "<<netSalary;
}