Skip to content

Commit 823c7d3

Browse files
authored
Refactor transactionClass for tax calculation logic
1 parent 9eba7fa commit 823c7d3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/pkg2darr_payrollsystem/transactionClass.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public static void Transaction()
1717
taxRate = 0;
1818
if(statusChoice == 1)
1919
{
20+
numDepEmployee[i] = "0" + "(0%)";
2021
statusEmployee[i] = "Single" + "(6%)";
2122
taxRate = 0.06;
2223
}
@@ -33,7 +34,7 @@ else if(numDepChoice == 2)
3334
numDepEmployee[i] = "2" + "(2%)";
3435
taxRate = 0.02;
3536
}
36-
else if(numDepChoice == 3)
37+
else if(numDepChoice >= 3)
3738
{
3839
numDepEmployee[i] = "3" + "(0%)";
3940
taxRate = 0.00;
@@ -71,14 +72,14 @@ else if(numDepChoice == 2)
7172
numDepEmployee[i] = "2" + "(2%)";
7273
taxRate = 0.02;
7374
}
74-
else if(numDepChoice == 3)
75+
else if(numDepChoice >= 3)
7576
{
7677
numDepEmployee[i] = "3" + "(0%)";
7778
taxRate = 0.00;
7879
}
7980
}
8081

81-
double vat = dataEmployee[i][12] * taxRate;
82+
vat = dataEmployee[i][12] * taxRate;
8283
dataEmployee[i][15] = vat;
8384
dataEmployee[i][13] = dataEmployee[i][12] - dataEmployee[i][9] - vat; //Net pay
8485
totalPay += dataEmployee[i][13]; //total net pay of employees
@@ -94,3 +95,4 @@ public static void Deduction()
9495
}
9596
}
9697

98+

0 commit comments

Comments
 (0)