-
Notifications
You must be signed in to change notification settings - Fork 0
/
NETPAY.cpp
121 lines (97 loc) · 4.64 KB
/
NETPAY.cpp
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
112
113
114
115
116
117
118
119
120
121
//this C++ program is open to contributions and editing.
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
//declaration of variables that will hold the various parameters of the program
float workedHours, overtime, workedIncome, overtimeIncome, grossPay = 0.0, regularHours, socialSecurity=0.06, constituencyTax=0.03,deduction, welfare=0.02, netSalary;
const float weeklyHours = 40;
string name;
int pin;
const int dependants=3;
int noDependants;
int excessDependants;
//this section allows vrious workers to enter their username and pin before inputing other details for determination of netpay.
cout<<"Enter your username:"<<endl;
cin>>name;
cout<<"Enter your pin :"<<endl;
cin>>pin;
// Taking the number of hours used for working from a user and the number of dependants of a user
cout << "Enter the number of worked hours in a week: " << endl;
cin >> workedHours;
cout << "Enter the number of dependants: " << endl;
cin>>noDependants;
// setting up a conditions to calculate the grosspay of a worker
if (workedHours <= weeklyHours) {
grossPay = workedHours * 25000.00;
cout << "Your grossPay is: " << fixed << setprecision(2) << grossPay << endl;
}
else {
regularHours = weeklyHours;
overtime = workedHours - weeklyHours;
grossPay = (regularHours * 25000.00) + (overtime * 1.5 * 25000.00);
cout << "Your grossPay is: " << fixed << setprecision(2) << grossPay << endl;
}
//setting up conditions that takes into consideration the user gross pay and the various taxes involved and return the netpay of a user
if (grossPay<125001){
if(noDependants>3){
excessDependants=noDependants-dependants;
}
netSalary=grossPay-((socialSecurity*grossPay)+(constituencyTax*grossPay)+(welfare*grossPay));
deduction=grossPay-netSalary;
float netPay=netSalary+(excessDependants*5000);
cout << "Your netPay is: " << fixed << setprecision(2) << netPay << endl;
cout << "amount deducted: " << fixed << setprecision(2) << deduction << endl;
}
else if(grossPay>125001&&grossPay<250000){
if(noDependants>3){
excessDependants=noDependants-dependants;
}
netSalary=grossPay-((socialSecurity*grossPay)+(constituencyTax*grossPay)+(welfare*grossPay)+(0.05*grossPay));
deduction=grossPay-netSalary;
float netPay=netSalary+(excessDependants*5000);
cout << "Your netPay is: " << fixed << setprecision(2) << netPay << endl;
cout << "amount deducted: " << fixed << setprecision(2) << deduction << endl;
}
else if(grossPay>250001&&grossPay<1750000){
if(noDependants>3){
excessDependants=noDependants-dependants;
}
netSalary=grossPay-((socialSecurity*grossPay)+(constituencyTax*grossPay)+(welfare*grossPay)+(0.1*grossPay));
deduction=grossPay-netSalary;
float netPay=netSalary+(excessDependants*5000);
cout << "Your netPay is: " << fixed << setprecision(2) << netPay << endl;
cout << "amount deducted: " << fixed << setprecision(2) << deduction << endl;
}
else if(grossPay>1750001&&grossPay<2750000){
if(noDependants>3){
excessDependants=noDependants-dependants;
}
netSalary=grossPay-((socialSecurity*grossPay)+(constituencyTax*grossPay)+(welfare*grossPay)+(0.15*grossPay));
deduction=grossPay-netSalary;
float netPay=netSalary+(excessDependants*5000);
cout << "Your netPay is: " << fixed << setprecision(2) << netPay << endl;
cout << "amount deducted: " << fixed << setprecision(2) << deduction << endl;
}
else if(grossPay>2750001&&grossPay<5000000){
netSalary=grossPay-((socialSecurity*grossPay)+(constituencyTax*grossPay)+(welfare*grossPay)+(0.2*grossPay));
deduction=grossPay-netSalary;
float netPay=netSalary+(excessDependants*5000);
cout << "Your netPay is: " << fixed << setprecision(2) << netPay << endl;
cout << "amount deducted: " << fixed << setprecision(2) << deduction << endl;
}
else if(grossPay>5000000){
if(noDependants>3){
excessDependants=noDependants-dependants;
}
netSalary=grossPay-((socialSecurity*grossPay)+(constituencyTax*grossPay)+(welfare*grossPay)+(0.3*grossPay));
deduction=grossPay-netSalary;
float netPay=netSalary+(excessDependants*5000);
cout << "Your netPay is: " << fixed << setprecision(2) << netPay << endl;
cout << "amount deducted: " << fixed << setprecision(2) << deduction << endl;
}
else{
cout << "Your grossPay is: " << fixed << setprecision(2) << grossPay << endl;
}
return 0;
}