YO
yogeshkumarsaini/Employee-Payroll-System
A simple Java console application that models employees, auto-calculates HRA/DA/PF, computes gross and net salary, and prints formatted payslips.
# Employee Payroll System (Java)
A simple console-based Employee Payroll System implemented in Java. This project demonstrates basic object-oriented design with an Employee class that automatically calculates allowances and deductions, a small interactive payroll application to add employees, and functionality to print formatted payslips.
## Features
- Employee model with:
- ID, name, and basic salary
- Calculated HRA (20%), DA (10%) and PF (5%)
- Methods to compute gross and net salary
- Interactive console application to:
- Add employees
- Display payslips for all added employees
- Exit the application
## Files
- Employee.java — Defines the Employee class and payroll calculations.
- PayrollSystem.java — Main application with a simple menu to add employees and display payslips.
## How it works
1. User selects "Add Employee" and provides ID, name, and basic salary.
2. The Employee constructor computes:
- HRA = 20% of basic salary
- DA = 10% of basic salary
- PF = 5% of basic salary
3. Gross salary = basic + HRA + DA
4. Net salary = gross - PF
5. Selecting "Show All Payslips" prints a formatted payslip for each employee.
## Usage
Compile:javac Employee.java PayrollSystem.java
Run:
java PayrollSystem
Follow the menu prompts to add employees and view payslips.
## Example Payslip (sample output)
------------ PAYSLIP ------------
Employee ID : 101
Name : Alice
Basic Salary: 50000.0
HRA (20%) : 10000.0
DA (10%) : 5000.0
PF (5%) : 2500.0
---------------------------------
Gross Salary: 65000.0
Net Salary : 62500.0
---------------------------------
## Extending / Next steps
- Persist employees to file (CSV/JSON) or a database.
- Add validation for user input and handle duplicate IDs.
- Add unit tests for payroll calculations.
- Create a GUI or web interface.
- Package as an executable JAR.
## License
MIT License — feel free to reuse and adapt for learning or demos.
## Contributing
Open an issue or submit a pull request with improvements or bug fixes.