0% found this document useful (0 votes)
34 views5 pages

HRMS

The document describes a Java program that implements an HR management system. The system allows users to add, remove, and update employee records, mark attendance, evaluate performance, and view reports. It uses object-oriented design with an Employee class to represent employees and store their details and records.

Uploaded by

rivor41640
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views5 pages

HRMS

The document describes a Java program that implements an HR management system. The system allows users to add, remove, and update employee records, mark attendance, evaluate performance, and view reports. It uses object-oriented design with an Employee class to represent employees and store their details and records.

Uploaded by

rivor41640
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

HR Management System

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;

class Employee {
int empId;
String name;
String department;
String position;
Map<String, Integer> attendance; // Store attendance: Date -> Hours
int performanceScore; // Performance evaluation score

public Employee(int empId, String name, String department, String position) {


this.empId = empId;
this.name = name;
this.department = department;
this.position = position;
this.attendance = new HashMap<>();
this.performanceScore = 0;
}

public void markAttendance(String date, int hours) {


attendance.put(date, hours);
}

public void setPerformanceScore(int score) {


this.performanceScore = score;
}

public int getPerformanceScore() {


return performanceScore;
}
}

public class HRManagementSystem {


ArrayList<Employee> employees;
Scanner scanner;

public HRManagementSystem() {
this.employees = new ArrayList<>();
this.scanner = new Scanner(System.in);
}

public void addEmployee() {


System.out.println("Enter Employee ID:");
int empId = scanner.nextInt();
scanner.nextLine(); // Consume newline
System.out.println("Enter Employee Name:");
String name = scanner.nextLine();
System.out.println("Enter Employee Department:");
String department = scanner.nextLine();
System.out.println("Enter Employee Position:");
String position = scanner.nextLine();

Employee employee = new Employee(empId, name, department, position);


employees.add(employee);
System.out.println("Employee " + name + " added successfully.");
}

public void removeEmployee(int empId) {


Iterator<Employee> iterator = employees.iterator();
while (iterator.hasNext()) {
Employee employee = iterator.next();
if (employee.empId == empId) {
iterator.remove();
System.out.println("Employee " + employee.name + " removed
successfully.");
return;
}
}
System.out.println("Employee not found.");
}

public void updateEmployee(int empId) {


for (Employee employee : employees) {
if (employee.empId == empId) {
System.out.println("Enter new Employee Name:");
String name = scanner.nextLine();
System.out.println("Enter new Employee Department:");
String department = scanner.nextLine();
System.out.println("Enter new Employee Position:");
String position = scanner.nextLine();

employee.name = name;
employee.department = department;
employee.position = position;
System.out.println("Employee details updated successfully.");
return;
}
}
System.out.println("Employee not found.");
}

public void markAttendance(int empId) {


for (Employee employee : employees) {
if (employee.empId == empId) {
System.out.println("Enter Date (YYYY-MM-DD):");
String date = scanner.nextLine();
System.out.println("Enter Hours Worked:");
int hours = scanner.nextInt();
employee.markAttendance(date, hours);
System.out.println("Attendance marked successfully for Employee " +
employee.name + ".");
return;
}
}
System.out.println("Employee not found.");
}

public void evaluatePerformance(int empId) {


for (Employee employee : employees) {
if (employee.empId == empId) {
System.out.println("Enter Performance Score (0-100):");
int score = scanner.nextInt();
employee.setPerformanceScore(score);
System.out.println("Performance evaluated successfully for Employee " +
employee.name + ".");
return;
}
}
System.out.println("Employee not found.");
}

public void displayAttendanceReport(int empId) {


for (Employee employee : employees) {
if (employee.empId == empId) {
System.out.println("Attendance Report for Employee " + employee.name +
":");
System.out.println(employee.attendance);
return;
}
}
System.out.println("Employee not found.");
}

public void displayPerformanceReport(int empId) {


for (Employee employee : employees) {
if (employee.empId == empId) {
System.out.println("Performance Report for Employee " + employee.name +
":");
System.out.println("Performance Score: " +
employee.getPerformanceScore());
return;
}
}
System.out.println("Employee not found.");
}

public void displayEmployees() {


if (employees.isEmpty()) {
System.out.println("No employees found.");
return;
}
System.out.println("Employee List:");
for (Employee employee : employees) {
System.out.println("ID: " + employee.empId + ", Name: " + employee.name +
", Department: " + employee.department + ", Position: " +
employee.position);
System.out.println("Attendance: " + employee.attendance);
System.out.println("Performance Score: " + employee.getPerformanceScore());
System.out.println();
}
}

// Sample usage
public static void main(String[] args) {
HRManagementSystem hrSystem = new HRManagementSystem();
Scanner scanner = new Scanner(System.in);

char choice;
do {
System.out.println("Select Operation:");
System.out.println("1. Add Employee");
System.out.println("2. Remove Employee");
System.out.println("3. Update Employee Details");
System.out.println("4. Mark Attendance");
System.out.println("5. Evaluate Performance");
System.out.println("6. View Attendance Report");
System.out.println("7. View Performance Report");
System.out.println("8. Display Employees");
System.out.println("9. Go Back");

int operation = scanner.nextInt();

switch (operation) {
case 1:
hrSystem.addEmployee();
break;
case 2:
System.out.println("Enter Employee ID to Remove:");
int empIdToRemove = scanner.nextInt();
hrSystem.removeEmployee(empIdToRemove);
break;
case 3:
System.out.println("Enter Employee ID to Update:");
int empIdToUpdate = scanner.nextInt();
scanner.nextLine(); // Consume newline
hrSystem.updateEmployee(empIdToUpdate);
break;
case 4:
System.out.println("Enter Employee ID to Mark Attendance:");
int empIdToMarkAttendance = scanner.nextInt();
scanner.nextLine(); // Consume newline
hrSystem.markAttendance(empIdToMarkAttendance);
break;
case 5:
System.out.println("Enter Employee ID to Evaluate Performance:");
int empIdToEvaluatePerformance = scanner.nextInt();
hrSystem.evaluatePerformance(empIdToEvaluatePerformance);
break;
case 6:
System.out.println("Enter Employee ID to View Attendance Report:");
int empIdForAttendanceReport = scanner.nextInt();
hrSystem.displayAttendanceReport(empIdForAttendanceReport);
break;
case 7:
System.out.println("Enter Employee ID to View Performance Report:");
int empIdForPerformanceReport = scanner.nextInt();
hrSystem.displayPerformanceReport(empIdForPerformanceReport);
break;
case 8:
hrSystem.displayEmployees();
break;
case 9:
// Allow HR professional to go back to the main menu
break;
default:
System.out.println("Invalid Operation.");
}

System.out.println("Do you want to continue? (Y/N)");


choice = scanner.next().charAt(0);
scanner.nextLine(); // Consume newline
} while (choice == 'Y' || choice == 'y');

scanner.close(); // Close the scanner before exiting


}
}

You might also like