Employee Management System using Java With Source Code

emplpuyee

Introduction :

Welcome to Employee Management System! It is a simple management tool using java that helps to add employees, view employee details, and remove employees from the system. The system is very handy and works on the admin panel. It is made using java which ensures security at a higher rate. In this new world where all new technologies are overtaking old ones, Java is still surviving and competing with all of them single-handedly. It is one of the most powerful languages,s, especially from a security point of view. Coming back to our employee management system, it is quite easy to use where the admin can add employees on his/her requirements and can view details of employees, and remove employees from the record. The whole process is too easy for the admin which makes this system flexible.

Explanation :

Employee Management System is fully made using the core concepts of java language. It is a system that gives us choices such as – Add Employee, Remove Employee, Display Employees and Exit. We need to import two inbuilt classes where first is Scanner which is used to take input from the user through the keyboard and the second is ArrayList which is part of the collection framework. ArrayList has read-made methods like add and remove which reduces the extra code for our program. Three classes have been made here – 1. Employee 2. EmployeeManagementSystem 3. employeeManagment. Employee class is holding all the necessary getter-setter methods to get and set the employee details like his/her id, age, salary, etc. We have overridden the toString() method in the Employee class to display all the details of the employee in a proper format. In EmployeeManagementSystem class firstly, we have made one object of ArrayList which is further used for adding, displaying, and removing employees. For adding the employee ‘add’ method, removing the employee ‘remove’ method is used with the object of the class. ‘Add’ and ‘Remove’ are the inbuilt methods of ArrayList. For displaying employees, each loop is used which is displaying details of all the employees present in the record. employee management class consists of the main method and switch case where we are calling the respective methods to operate the specific function. For adding an employee, details have been taken and it has been passed to the object of the Employee class. After that simply with the object of EmployeeManagementSystem, we have called the add method. Similarly, the process for removing employees from the system has taken place, the only difference is that process of removal is ID specific. Displaying details of employees is a very easy task, just by calling method displays employee’s details. The last option is for exiting the program which is simply taking place by breaking the loop. Classes, Objects, and ArrayList is the soul of this system. It is quite easy to code and understand this system with having some basic knowledge of OOPS. Happy Coding! 

Get Discount on Top Educational Courses

Brand NameDiscount InformationCoupon Codes Link
Educative.io20% discount on Educative courses and plans
W3Schools20% discount on W3Schools courses
KodeKloud10% discount on KodeKloud courses and plans
GeeksforGeeks30% discount on GeeksforGeeks courses
Target Test Prep20% discount on Target Test Prep
Coding Ninjas₹5000 discount on Coding Ninjas courses
Skillshare40% discount on Skillshare
DataCamp50% discount on DataCamp
365 Data Science57% discount on 365 Data Science Plans
Get SmarterFlat 20% discount on Get Smarter courses
SmartKeedaFlat 40% discount on SmartKeeda courses
StackSocial20% discount on StackSocial courses

Source Code

				
					import java.util.ArrayList;
import java.util.Scanner;

class Employee {
  private int id;
  private String name;
  private int age;
  private double salary;

  public Employee(int id, String name, int age, double salary) {
    this.id = id;
    this.name = name;
    this.age = age;
    this.salary = salary;
  }

  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public int getAge() {
    return age;
  }

  public void setAge(int age) {
    this.age = age;
  }

  public double getSalary() {
    return salary;
  }

  public void setSalary(double salary) {
    this.salary = salary;
  }

  @Override
  public String toString() {
    return "Employee [id=" + id + ", name=" + name + ", age=" + age + ", salary=" + salary + "]";
  }
}

class EmployeeManagementSystem {
  private ArrayList<Employee> employees = new ArrayList<Employee>();

  public void addEmployee(Employee e) {
    employees.add(e);
  }

  public void removeEmployee(int id) {
    for (int i = 0; i < employees.size(); i++) {
      Employee e = employees.get(i);
      if (e.getId() == id) {
        employees.remove(i);
        break;
      }
    }
  }

  public void displayEmployees() {
    for (Employee e : employees) {
      System.out.println(e);
    }
  }
}

public class employeeManagment {
  public static void main(String[] args) {
    EmployeeManagementSystem ems = new EmployeeManagementSystem();
    Scanner sc = new Scanner(System.in);
    int choice = 0;
    while (choice != 4) {
      System.out.println("1. Add Employee");
      System.out.println("2. Remove Employee");
      System.out.println("3. Display Employees");
      System.out.println("4. Exit");
      System.out.print("Enter your choice: ");
      choice = sc.nextInt();
      sc.nextLine();
      switch (choice) {
        case 1:
          System.out.print("Enter Employee ID: ");
          int id = sc.nextInt();
          sc.nextLine();
          System.out.print("Enter Employee Name: ");
          String name = sc.nextLine();
          System.out.print("Enter Employee Age: ");
          int age = sc.nextInt();
          sc.nextLine();
          System.out.print("Enter Employee Salary: ");
          double salary = sc.nextDouble();
          sc.nextLine();
          Employee e = new Employee(id, name, age, salary);
          ems.addEmployee(e);
          System.out.println("Employee added successfully!");
          break;
          case 2:
          System.out.print("Enter Employee ID to remove: ");
          int removeId = sc.nextInt();
          sc.nextLine();
          ems.removeEmployee(removeId);
          System.out.println("Employee removed successfully!");
          break;
          case 3:
          System.out.println("List of Employees:");
          ems.displayEmployees();
          break;
          case 4:
          System.out.println("Exiting Employee Management System...");
          break;
          default:
          System.out.println("Invalid choice. Try again.");
          break;
          }
          }
          sc.close();
          }
          }
				
			

Find More Projects

URL Shortener Using Python Django Introduction: Long URLs can be shortened into short, shareable links with the help of the URL Shortener …

User Authentication System Using Python Django Introduction: The implementation of safe and adaptable user authentication in Django is the main goal of …

The E-Learning System using Java with a Graphical User Interface (GUI) Introduction The E-Learning System is developed using Java (with a Graphical …

Weather App Using Python Django Introduction: When a user enters the name of a city, the Weather App retrieves current weather information. …

Quiz App Using Python Django Introduction: Users can take quizzes in a variety of subjects, see their results, and monitor their progress …

resume screener in python using python introduction The hiring process often begins with reviewing numerous resumes to filter out the most suitable …

Get Huge Discounts
More java Pojects