The Java Employee Management System is a console-based application that allows users to manage employee records. The application supports adding, viewing, searching, updating, deleting employees, and calculating salary.
Project Features
- Add Employee
- View All Employees
- Search Employee by ID
- Update Employee Details
- Delete Employee
- Calculate Annual Salary
- Exit Application
Project Structure
EmployeeManagement
│
├── Employee.java
├── EmployeeManager.java
└── EmployeeManagement.java
File 1: Employee.java
public class Employee {
private int id;
private String name;
private String department;
private double salary;
public Employee(int id, String name, String department, double salary) {
this.id = id;
this.name = name;
this.department = department;
this.salary = salary;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public String getDepartment() {
return department;
}
public double getSalary() {
return salary;
}
public void setName(String name) {
this.name = name;
}
public void setDepartment(String department) {
this.department = department;
}
public void setSalary(double salary) {
this.salary = salary;
}
}
File 2: EmployeeManager.java
import java.util.ArrayList;
public class EmployeeManager {
private ArrayList employees = new ArrayList();
public void addEmployee(Employee employee) {
employees.add(employee);
System.out.println("Employee Added Successfully.");
}
public void displayEmployees() {
if (employees.isEmpty()) {
System.out.println("No Employee Found.");
return;
}
System.out.println();
for (Employee emp : employees) {
System.out.println("----------------------------");
System.out.println("ID : " + emp.getId());
System.out.println("Name : " + emp.getName());
System.out.println("Department : " + emp.getDepartment());
System.out.println("Salary : " + emp.getSalary());
}
}
public void searchEmployee(int id) {
for (Employee emp : employees) {
if (emp.getId() == id) {
System.out.println("Employee Found");
System.out.println("ID : " + emp.getId());
System.out.println("Name : " + emp.getName());
System.out.println("Department : " + emp.getDepartment());
System.out.println("Salary : " + emp.getSalary());
return;
}
}
System.out.println("Employee Not Found.")
}
public void updateEmployee(int id,
String name,
String department,
double salary) {
for (Employee emp : employees) {
if (emp.getId() == id) {
emp.setName(name);
emp.setDepartment(department);
emp.setSalary(salary);
System.out.println("Employee Updated Successfully.");
return;
}
}
System.out.println("Employee Not Found.");
}
public void deleteEmployee(int id) {
for (Employee emp : employees) {
if (emp.getId() == id) {
employees.remove(emp);
System.out.println("Employee Deleted Successfully.");
return;
}
}
System.out.println("Employee Not Found.");
}
public void annualSalary(int id) {
for (Employee emp : employees) {
if (emp.getId() == id) {
System.out.println("Annual Salary : " +
(emp.getSalary() * 12));
return;
}
}
System.out.println("Employee Not Found.");
}
}
File 3: EmployeeManagement.java
import java.util.Scanner;
public class EmployeeManagement {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
EmployeeManager manager = new EmployeeManager();
int choice;
do {
System.out.println("\n========== EMPLOYEE MANAGEMENT ==========");
System.out.println("1. Add Employee");
System.out.println("2. View Employees");
System.out.println("3. Search Employee");
System.out.println("4. Update Employee");
System.out.println("5. Delete Employee");
System.out.println("6. Annual Salary");
System.out.println("7. Exit");
System.out.print("Enter Choice : ");
choice = scanner.nextInt();
switch (choice) {
case 1:
System.out.print("Employee ID : ");
int id = scanner.nextInt();
scanner.nextLine();
System.out.print("Employee Name : ");
String name = scanner.nextLine();
System.out.print("Department : ");
String department = scanner.nextLine();
System.out.print("Monthly Salary : ");
double salary = scanner.nextDouble();
manager.addEmployee(
new Employee(id, name, department, salary));
break;
case 2:
manager.displayEmployees();
break;
case 3:
System.out.print("Enter Employee ID : ");
manager.searchEmployee(scanner.nextInt());
break;
case 4:
System.out.print("Employee ID : ");
id = scanner.nextInt();
scanner.nextLine();
System.out.print("New Name : ");
name = scanner.nextLine();
System.out.print("New Department : ");
department = scanner.nextLine();
System.out.print("New Salary : ");
salary = scanner.nextDouble();
manager.updateEmployee(id,
name,
department,
salary);
break;
case 5:
System.out.print("Enter Employee ID : ");
manager.deleteEmployee(scanner.nextInt());
break;
case 6:
System.out.print("Enter Employee ID : ");
manager.annualSalary(scanner.nextInt());
break;
case 7:
System.out.println("Thank You!");
break;
default:
System.out.println("Invalid Choice.");
}
} while (choice != 7);
scanner.close();
}
}
Sample Output
========== EMPLOYEE MANAGEMENT ==========
1. Add Employee
2. View Employees
3. Search Employee
4. Update Employee
5. Delete Employee
6. Annual Salary
7. Exit
Enter Choice : 1
Employee ID : 101
Employee Name : John Smith
Department : IT
Monthly Salary : 45000
Employee Added Successfully.
View Employees
----------------------------
ID : 101
Name : John Smith
Department : IT
Salary : 45000.0
Search Employee
Enter Employee ID : 101
Employee Found
ID : 101
Name : John Smith
Department : IT
Salary : 45000.0
Update Employee
Employee ID : 101
New Name : John David
New Department : Development
New Salary : 52000
Employee Updated Successfully.
Delete Employee
Enter Employee ID : 101
Employee Deleted Successfully.
Calculate Annual Salary
Enter Employee ID : 101
Annual Salary : 624000.0
Java Concepts Used
- Classes and Objects
- Encapsulation
- Constructors
- Getters and Setters
- ArrayList
- Scanner Class
- Loops
- Switch Statement
- Methods
- CRUD Operations (Create, Read, Update, Delete)
Possible Enhancements
- Employee Login
- Admin Login
- Attendance Management
- Leave Management
- Payroll Generation
- Bonus Calculation
- Tax Calculation
- Department-wise Employee List
- Search by Name
- Sort Employees by Salary
- Save Data Using File Handling
- MySQL Database Integration
- Java Swing or JavaFX GUI
- Spring Boot REST API
- Export Employee Data to CSV or Excel
Conclusion
This Java Employee Management System is a complete beginner-friendly project that demonstrates how to perform CRUD operations using Java and Object-Oriented Programming. The code is modular, easy to understand, and can be extended with advanced features such as database connectivity, graphical user interfaces, authentication, and reporting.