From 9143a9beb80e654c0536d610d1778bb949e50be1 Mon Sep 17 00:00:00 2001 From: "Andrei Jiroh Halili (STI College Meycauayan)" Date: Mon, 29 Sep 2025 11:25:38 +0800 Subject: [PATCH] feat: ship 04 Performance Task Signed-off-by: Andrei Jiroh Halili (STI College Meycauayan) --- .../projects/ComProgPETA_netPay.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 java/src/dev/andreijiroh/studentops/projects/ComProgPETA_netPay.java diff --git a/java/src/dev/andreijiroh/studentops/projects/ComProgPETA_netPay.java b/java/src/dev/andreijiroh/studentops/projects/ComProgPETA_netPay.java new file mode 100644 index 0000000..def6a82 --- /dev/null +++ b/java/src/dev/andreijiroh/studentops/projects/ComProgPETA_netPay.java @@ -0,0 +1,44 @@ +package dev.andreijiroh.studentops.projects; + +/** + * Computer Programming 1 - 04 Performance Task + * @author Andrei Jiroh Eugenio Halili (STI College Meycauayan) + */ +public class ComProgPETA_netPay { + public static void main(String[] args) { + String employeeName = "Magdalena Leones"; + long employeeId = 4594910906L; + int monthlySalary = 35000; + + /** + * This class stores the static values ffor different percentages on deductions for maintainability. + */ + class deductionFormula { + static public double taxRate = 0.12f; + static public double socialSecurity = 0.045f; + static public double pagibigContributions = 200f; + } + + // this is where the math happens + double socialSecurity = Math.round((monthlySalary * deductionFormula.socialSecurity) * 100f) / 100f; + double totalDeductions = socialSecurity + deductionFormula.pagibigContributions; + double withholdingTax = Math.round(((monthlySalary - totalDeductions) * deductionFormula.taxRate) * 100f / 100f); + + // finally output the reasults as if it's a payslip + System.out.println("EMPLOYEE PAYSLIP - 2025-09-29"); + System.out.println("Note that all of the amounts are written in PHP (Philippine Peso)."); + System.out.println(); + System.out.println("Name: "+employeeName); + System.out.println("Employee ID: "+employeeId); + System.out.println(); + System.out.println("GROSS PAY: "+monthlySalary); + System.out.println(); + System.out.println("DEDUCTIONS"); + System.out.println("Social security (SSS): "+socialSecurity); + System.out.println("HDMF / PAG-IBIG Savings: "+deductionFormula.pagibigContributions); + System.out.println("Total deductions before tax: "+ totalDeductions); + System.out.println("Withholding tax: "+withholdingTax); + System.out.println(); + System.out.println("NET PAY: "+ (monthlySalary - totalDeductions - withholdingTax)); + } +} -- 2.51.2