Saturday, December 28, 2024
Google search engine
HomeData Modelling & AIProgram for Employee Management System

Program for Employee Management System

A Employee’s Management System (EMS) is a software built to handle the primary housekeeping functions of a company. EMS help companies keep track of all the employees and their records. It is used to manage the company using computerized system.

Aim of Employee’s Management System: 

  • Built The Employee Table.
  • Insert New Entries.
  • Delete The Entries.
  • Search A Record.

Data of the Employee’s:

  • Name 
  • Employee ID
  • Designation
  • Experience
  • Age

Approach:

  1. For storing the data of the employee, create a user define datatype which will store the information regarding Employee. Below is the declaration of the data type:
struct employee {
  string name;
  long int code;
  string designation;
  int exp;
  int age;
};
  1. Building the Employee’s table: For building the employee table the idea is to use the array of the above struct datatype which will use to store the information regarding employee. For storing information at index i the data is stored as:
struct employee emp[10];
emp[i].name = "neveropen"
emp[i].code = "12345"
emp[i].designation = "Organisation"
emp[i].exp = 10
emp[i].age = 10
  1. Deleting in the record: Since we are using array to store the data, therefore to delete the data at any index shift all the data at that index by 1 and delete the last data of the array by decreasing the size of array by 1.
  2. Searching in the record: For searching in the record based on any parameter, the idea is to traverse the data and if at any index the value parameters matches with the record stored, print all the information of that employee.

Below is the implementation of Employee Management system in C:

C++




// C++ program for the above approach
#include <bits/stdc++.h>
 
#define max 20
using namespace std;
 
// Structure of Employee
struct employee {
    string name;
    long int code;
    string designation;
    int exp;
    int age;
};
 
int num;
void showMenu();
 
// Array of Employees to store the
// data in the form of the Structure
// of the Array
employee emp[max], tempemp[max],
    sortemp[max], sortemp1[max];
 
// Function to build the given datatype
void build()
{
    cout << "Build The Table\n";
    cout << "Maximum Entries can be "
         << max << "\n";
 
    cout << "Enter the number of "
         << "Entries required";
    cin >> num;
 
    if (num > 20) {
        cout << "Maximum number of "
             << "Entries are 20\n";
        num = 20;
    }
    cout << "Enter the following data:\n";
 
    for (int i = 0; i < num; i++) {
        cout << "Name ";
        cin >> emp[i].name;
 
        cout << "Employee ID ";
        cin >> emp[i].code;
 
        cout << "Designation ";
        cin >> emp[i].designation;
 
        cout << "Experience ";
        cin >> emp[i].exp;
 
        cout << "Age ";
        cin >> emp[i].age;
    }
 
    showMenu();
}
 
// Function to insert the data into
// given data type
void insert()
{
    if (num < max) {
        int i = num;
        num++;
 
        cout << "Enter the information "
             << "of the Employee\n";
        cout << "Name ";
        cin >> emp[i].name;
 
        cout << "Employee ID ";
        cin >> emp[i].code;
 
        cout << "Designation ";
        cin >> emp[i].designation;
 
        cout << "Experience ";
        cin >> emp[i].exp;
 
        cout << "Age ";
        cin >> emp[i].age;
    }
    else {
        cout << "Employee Table Full\n";
    }
 
    showMenu();
}
 
// Function to delete record at index i
void deleteIndex(int i)
{
    for (int j = i; j < num - 1; j++) {
        emp[j].name = emp[j + 1].name;
        emp[j].code = emp[j + 1].code;
        emp[j].designation
            = emp[j + 1].designation;
        emp[j].exp = emp[j + 1].exp;
        emp[j].age = emp[j + 1].age;
    }
    return;
}
 
// Function to delete record
void deleteRecord()
{
    cout << "Enter the Employee ID "
         << "to Delete Record";
 
    int code;
 
    cin >> code;
    for (int i = 0; i < num; i++) {
        if (emp[i].code == code) {
            deleteIndex(i);
            num--;
            break;
        }
    }
    showMenu();
}
 
void searchRecord()
{
    cout << "Enter the Employee"
         << " ID to Search Record";
 
    int code;
    cin >> code;
 
    for (int i = 0; i < num; i++) {
 
        // If the data is found
        if (emp[i].code == code) {
            cout << "Name "
                 << emp[i].name << "\n";
 
            cout << "Employee ID "
                 << emp[i].code << "\n";
 
            cout << "Designation "
                 << emp[i].designation << "\n";
 
            cout << "Experience "
                 << emp[i].exp << "\n";
 
            cout << "Age "
                 << emp[i].age << "\n";
            break;
        }
    }
 
    showMenu();
}
 
// Function to show menu
void showMenu()
{
 
    cout << "-------------------------"
         << "neveropen Employee"
         << " Management System"
         << "-------------------------\n\n";
 
    cout << "Available Options:\n\n";
    cout << "Build Table         (1)\n";
    cout << "Insert New Entry    (2)\n";
    cout << "Delete Entry        (3)\n";
    cout << "Search a Record     (4)\n";
    cout << "Exit                (5)\n";
 
    int option;
 
    // Input Options
    cin >> option;
 
    // Call function on the basis of the
    // above option
    if (option == 1) {
        build();
    }
    else if (option == 2) {
        insert();
    }
    else if (option == 3) {
        deleteRecord();
    }
    else if (option == 4) {
        searchRecord();
    }
    else if (option == 5) {
        return;
    }
    else {
        cout << "Expected Options"
             << " are 1/2/3/4/5";
        showMenu();
    }
}
 
// Driver Code
int main()
{
 
    showMenu();
    return 0;
}


Java




/*package whatever //do not write package name here */
 
import java.util.*;
 
class GFG {
   
  // Class of Employee
static class employee{
    String name;
    long code;
    String designation;
    int exp;
    int age;
}
 
static int num;
static int max = 20;
// Array of Employees to store the
// data in the form of the Structure
// of the Array
static employee emp[] = new employee[max];
static employee tempemp[] = new employee[max];
static employee sortemp[] = new employee[max];
static employee sortemp1[] = new employee[max];
static  Scanner sc = new Scanner(System.in);  
// Function to build the given datatype
static void build()
{
     System.out.println("Build The Table\n");
     System.out.println("Maximum Entries can be " + max);
 
     System.out.println("Enter the number of " + "Entries required");
  
   
  num = sc.nextInt();
 
    if (num > 20) {
         System.out.println("Maximum number of "+"Entries are 20");
        num = 20;
    }
     System.out.println("Enter the following data:");
 
    for (int i = 0; i < num; i++) {
        System.out.print("Name ");
        emp[i].name = sc.next();
 
        System.out.print("Employee ID ");
        emp[i].code = sc.nextLong();
 
        System.out.print("Designation ");
        emp[i].designation = sc.next();
 
        System.out.print("Experience ");
        emp[i].exp = sc.nextInt();
 
        System.out.print("Age ");
        emp[i].age = sc.nextInt();
    }
 
    showMenu();
}
 
// Function to insert the data into
// given data type
static void insert()
{
    if (num < max) {
        int i = num;
        num++;
 
        System.out.print("Enter the information " + "of the Employee");
        System.out.print("Name ");
        emp[i].name = sc.next();
 
        System.out.print("Employee ID ");
        emp[i].code = sc.nextLong();
 
        System.out.print("Designation ");
        emp[i].designation = sc.next();
 
        System.out.print("Experience ");
        emp[i].exp = sc.nextInt();
 
        System.out.print("Age ");
        emp[i].age = sc.nextInt();
    }
    else {
        System.out.println("Employee Table Full");
    }
 
    showMenu();
}
 
// Function to delete record at index i
static void deleteIndex(int i)
{
    for (int j = i; j < num - 1; j++) {
        emp[j].name = emp[j + 1].name;
        emp[j].code = emp[j + 1].code;
        emp[j].designation = emp[j + 1].designation;
        emp[j].exp = emp[j + 1].exp;
        emp[j].age = emp[j + 1].age;
    }
    return;
}
 
// Function to delete record
static void deleteRecord()
{
    System.out.println("Enter the Employee ID "+ "to Delete Record");
 
    int code = sc.nextInt();
 
   
    for (int i = 0; i < num; i++) {
        if (emp[i].code == code) {
            deleteIndex(i);
            num--;
            break;
        }
    }
    showMenu();
}
 
static void searchRecord()
{
    System.out.println("Enter the Employee"+" ID to Search Record");
 
    int code = sc.nextInt();
 
    for (int i = 0; i < num; i++) {
 
        // If the data is found
        if (emp[i].code == code) {
            System.out.println("Name " + emp[i].name);
 
            System.out.println("Employee ID " + emp[i].code);
 
            System.out.println("Designation " + emp[i].designation);
 
            System.out.println("Experience " + emp[i].exp);
 
            System.out.println("Age " + emp[i].age);
            break;
        }
    }
 
    showMenu();
}
 
// Function to show menu
static void showMenu()
{
 
    System.out.println("-------------------------"
         + "neveropen Employee"
         + " Management System"
         + "-------------------------\n");
 
    System.out.println("Available Options:\n");
    System.out.print("Build Table         (1)\n");
    System.out.print("Insert New Entry    (2)\n");
    System.out.print("Delete Entry        (3)\n");
    System.out.print("Search a Record     (4)\n");
    System.out.print("Exit                (5)\n");
 
    int option = sc.nextInt();
 
    // Input Options
    // Call function on the basis of the
    // above option
    if (option == 1) {
        build();
    }
    else if (option == 2) {
        insert();
    }
    else if (option == 3) {
        deleteRecord();
    }
    else if (option == 4) {
        searchRecord();
    }
    else if (option == 5) {
        return;
    }
    else {
        System.out.println("Expected Options" + " are 1/2/3/4/5");
        showMenu();
    }
}
   
    public static void main (String[] args) {
       showMenu();
    }
}
 
// This code is contributed by aadityaburujwale.


Python3




max = 20
 
# Structure of Employee
class employee:
    def __init__(self):
        self.name = ''
        self.code = 0
        self.designation = ''
        self.exp = 0
        self.age = 0
 
num = 0
emp = [employee() for i in range(max)]
tempemp = [employee() for i in range(max)]
sortemp = [employee() for i in range(max)]
sortemp1 = [employee() for i in range(max)]
 
# Function to build the given datatype
def build():
    global num, emp
 
    print("Build The Table")
    print("Maximum Entries can be", max)
 
    num = int(input("Enter the number of Entries required: "))
 
    if num > max:
        print("Maximum number of Entries are 20")
        num = 20
 
    print("Enter the following data:")
    for i in range(num):
        emp[i].name = input("Name: ")
        emp[i].code = int(input("Employee ID: "))
        emp[i].designation = input("Designation: ")
        emp[i].exp = int(input("Experience: "))
        emp[i].age = int(input("Age: "))
 
    showMenu()
 
# Function to insert the data into
# given data type
def insert():
    global num, emp
 
    if num < max:
        i = num
        num += 1
 
        print("Enter the information of the Employee:")
        emp[i].name = input("Name: ")
        emp[i].code = int(input("Employee ID: "))
        emp[i].designation = input("Designation: ")
        emp[i].exp = int(input("Experience: "))
        emp[i].age = int(input("Age: "))
    else:
        print("Employee Table Full")
 
    showMenu()
 
# Function to delete record at index i
def deleteIndex(i):
    global num, emp
 
    for j in range(i, num - 1):
        emp[j].name = emp[j + 1].name
        emp[j].code = emp[j + 1].code
        emp[j].designation = emp[j + 1].designation
        emp[j].exp = emp[j + 1].exp
        emp[j].age = emp[j + 1].age
 
# Function to delete record
def deleteRecord():
    global num, emp
 
    code = int(input("Enter the Employee ID to Delete Record: "))
 
    for i in range(num):
        if emp[i].code == code:
            deleteIndex(i)
            num -= 1
            break
 
    showMenu()
 
def searchRecord():
    global num, emp
 
    code = int(input("Enter the Employee ID to Search Record: "))
 
    for i in range(num):
        # If the data is found
        if emp[i].code == code:
            print("Name:", emp[i].name)
            print("Employee ID:", emp[i].code)
            print("Designation:", emp[i].designation)
            print("Experience:", emp[i].exp)
            print("Age:", emp[i].age)
            break
 
    showMenu()
 
# Function to show menu
def showMenu():
    print("-------------------------neveropen Employee Management System-------------------------\n")
    print("Available Options:\n")
    print("Build Table         (1)")
    print("Insert New Entry    (2)")
    print("Delete Entry        (3)")
    print("Search a Record     (4)")
    print("Exit                (5)")
 
    # Input Options
    option = int(input())
 
    # Call
    if option == 1:
        build()
    elif option == 2 :
        insert()
    elif option == 3 :
        deleteRecord()
    elif option == 4 :
        searchRecord()
    elif option == 5 :
        return
    else:
        print("Expected Options")
        print("are 1/2/3/4/5")
        showMenu()
# Driver code
showMenu()
    


C#




using System;
using System.Collections.Generic;
 
public class GFG{
 
  // Class of Employee
  static class employee{
    public string name;
    public long code;
    public string designation;
    public int exp;
    public int age;
  }
 
  static int num;
  static int max = 20;
  // Array of Employees to store the
  // data in the form of the Structure
  // of the Array
  static employee[] emp = new employee[max];
  static employee[] tempemp = new employee[max];
  static employee[] sortemp = new employee[max];
  static employee[] sortemp1 = new employee[max];
  static Scanner sc = new Scanner(System.in);  
  // Function to build the given datatype
  static void build()
  {
    Console.WriteLine("Build The Table\n");
    Console.WriteLine("Maximum Entries can be " + max);
 
    Console.WriteLine("Enter the number of " + "Entries required");
 
 
    num = sc.nextInt();
 
    if (num > 20) {
      Console.WriteLine("Maximum number of "+"Entries are 20");
      num = 20;
    }
    Console.WriteLine("Enter the following data:");
 
    for (int i = 0; i < num; i++) {
      Console.Write("Name ");
      emp[i].name = sc.next();
 
      Console.Write("Employee ID ");
      emp[i].code = sc.nextLong();
 
      Console.Write("Designation ");
      emp[i].designation = sc.next();
 
      Console.Write("Experience ");
      emp[i].exp = sc.nextInt();
 
      Console.Write("Age ");
      emp[i].age = sc.nextInt();
    }
 
    showMenu();
  }
 
  // Function to insert the data into
  // given data type
  static void insert()
  {
    if (num < max) {
      int i = num;
      num++;
 
      Console.Write("Enter the information " + "of the Employee");
      Console.Write("Name ");
      emp[i].name = sc.next();
 
      Console.Write("Employee ID ");
      emp[i].code = sc.nextLong();
 
      Console.Write("Designation ");
      emp[i].designation = sc.next();
 
      Console.Write("Experience ");
      emp[i].exp = sc.nextInt();
 
      Console.Write("Age ");
      emp[i].age = sc.nextInt();
    }
    else {
      Console.WriteLine("Employee Table Full");
    }
 
    showMenu();
  }
 
  // Function to delete record at index i
  static void deleteIndex(int i)
  {
    for (int j = i; j < num - 1; j++) {
      emp[j].name = emp[j + 1].name;
      emp[j].code = emp[j + 1].code;
      emp[j].designation = emp[j + 1].designation;
      emp[j].exp = emp[j + 1].exp;
      emp[j].age = emp[j + 1].age;
    }
    return;
  }
 
  // Function to delete record
  static void deleteRecord()
  {
    Console.WriteLine("Enter the Employee ID "+ "to Delete Record");
 
    int code = sc.nextInt();
 
 
    for (int i = 0; i < num; i++) {
      if (emp[i].code == code) {
        deleteIndex(i);
        num--;
        break;
      }
    }
    showMenu();
  }
 
  static void searchRecord()
  {
    Console.WriteLine("Enter the Employee"+" ID to Search Record");
 
    int code = sc.nextInt();
 
    for (int i = 0; i < num; i++) {
 
      // If the data is found
      if (emp[i].code == code) {
        Console.WriteLine("Name " + emp[i].name);
 
        Console.WriteLine("Employee ID " + emp[i].code);
 
        Console.WriteLine("Designation " + emp[i].designation);
 
        Console.WriteLine("Experience " + emp[i].exp);
 
        Console.WriteLine("Age " + emp[i].age);
        break;
      }
    }
 
    showMenu();
  }
 
  // Function to show menu
  static void showMenu()
  {
 
    Console.WriteLine("-------------------------"
                      + "neveropen Employee"
                      + " Management System"
                      + "-------------------------\n");
 
    Console.WriteLine("Available Options:\n");
    Console.Write("Build Table         (1)\n");
    Console.Write("Insert New Entry    (2)\n");
    Console.Write("Delete Entry        (3)\n");
    Console.Write("Search a Record     (4)\n");
    Console.Write("Exit                (5)\n");
 
    int option = sc.nextInt();
 
    // Input Options
    // Call function on the basis of the
    // above option
    if (option == 1) {
      build();
    }
    else if (option == 2) {
      insert();
    }
    else if (option == 3) {
      deleteRecord();
    }
    else if (option == 4) {
      searchRecord();
    }
    else if (option == 5) {
      return;
    }
    else {
      Console.WriteLine("Expected Options" + " are 1/2/3/4/5");
      showMenu();
    }
  }
 
  static public void Main (){
    showMenu();
  }
}
 
// This code is contributed by akashish__


Javascript




// JavaScript program for the above approach
const max = 20;
 
// Structure of Employee
const employee = {
    name: "",
    code: 0,
    designation: "",
    exp: 0,
    age: 0
};
 
let num;
 
// Array of Employees to store the
// data in the form of the Structure
// of the Array
let emp = new Array(max);
let tempemp = new Array(max);
let sortemp = new Array(max);
let sortemp1 = new Array(max);
 
// Function to build the given datatype
function build () {
    console.log("Build The Table");
    console.log("Maximum Entries can be " + max);
 
    console.log("Enter the number of Entries required");
    num = prompt();
 
    if (num > 20) {
        console.log("Maximum number of Entries are 20");
        num = 20;
    }
    console.log("Enter the following data:");
 
    for (let i = 0; i < num; i++) {
        console.log("Name ");
        emp[i].name = prompt();
 
        console.log("Employee ID ");
        emp[i].code = prompt();
 
        console.log("Designation ");
        emp[i].designation = prompt();
 
        console.log("Experience ");
        emp[i].exp = prompt();
 
        console.log("Age ");
        emp[i].age = prompt();
    }
 
    showMenu();
}
 
// Function to insert the data into
// given data type
function insert() {
    if (num < max) {
        let i = num;
        num++;
 
        console.log("Enter the information of the Employee");
        console.log("Name ");
        emp[i].name = prompt();
 
        console.log("Employee ID ");
        emp[i].code = prompt();
 
        console.log("Designation ");
        emp[i].designation = prompt();
 
        console.log("Experience ");
        emp[i].exp = prompt();
 
        console.log("Age ");
        emp[i].age = prompt();
    }
    else {
        console.log("Employee Table Full");
    }
 
    showMenu();
}
 
// Function to delete record at index i
function deleteIndex (i) {
    for (let j = i; j < num - 1; j++) {
        emp[j].name = emp[j + 1].name;
        emp[j].code = emp[j + 1].code;
        emp[j].designation = emp[j + 1].designation;
        emp[j].exp = emp[j + 1].exp;
        emp[j].age = emp[j + 1].age;
    }
    return;
}
 
// Function to delete record
function deleteRecord() {
    console.log("Enter the Employee ID to Delete Record");
 
    let code = prompt();
    for (let i = 0; i < num; i++) {
        if (emp[i].code == code) {
            deleteIndex(i);
            num--;
            break;
        }
    }
    showMenu();
}
 
function searchRecord() {
    console.log("Enter the Employee ID to Search Record");
 
    let code = prompt();
 
    for (let i = 0; i < num; i++) {
 
        // If the data is found
        if (emp[i].code == code) {
            console.log("Name " + emp[i].name);
 
            console.log("Employee ID " + emp[i].code);
 
            console.log("Designation " + emp[i].designation);
 
            console.log("Experience " + emp[i].exp);
 
            console.log("Age " + emp[i].age);
            break;
        }
    }
 
    showMenu();
}
 
// Function to show menu
function showMenu() {
 
    console.log("-------------------------" +
    "neveropen Employee" +
    " Management System" +
    "-------------------------\n\n");
 
    console.log("Available Options:\n\n");
    console.log("Build Table         (1)\n");
    console.log("Insert New Entry    (2)\n");
    console.log("Delete Entry        (3)\n");
    console.log("Search a Record     (4)\n");
    console.log("Exit                (5)\n");
 
    let option = prompt();
 
    // Call function on the basis of the
    // above option
    if (option == 1) {
        build();
    } else if (option == 2) {
        insert();
    } else if (option == 3) {
        deleteRecord();
    } else if (option == 4) {
        searchRecord();
    } else if (option == 5) {
        return;
    } else {
        console.log("Expected Options are 1/2/3/4/5");
        showMenu();
    }
}
 
// Driver Code
function main() {
 
    showMenu();
    return 0;
}
 
// This code is contributed by akashish__


Output: Below is the output of the above program:

Feeling lost in the world of random DSA topics, wasting time without progress? It’s time for a change! Join our DSA course, where we’ll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 neveropen!

RELATED ARTICLES

Most Popular

Recent Comments