Question

In: Computer Science

Develop an algorithm to implement an employee list with employee ID ,name designation and department using...

Develop an algorithm to implement an employee list with employee ID ,name designation and department using link list and perform the following operation on the list

i)add employee details based on department

ii)remove employee details

iv)count the number of employee in each department

Solutions

Expert Solution

PLEASE GIVE IT A THUMBS UP, I SERIOUSLY NEED ONE, IF YOU NEED ANY MODIFICATION THEN LET ME KNOW, I WILL DO IT FOR YOU

#include <bits/stdc++.h>
using namespace std;
struct Employee
{

        int employeeID;
        string name;
        string designation;
        string department;
        Employee *next;
        Employee(int EmployeeID, string Name, string Designation, string Department)
        {
                employeeID = EmployeeID;
                name = Name;
                designation = Designation;
                department = Department;
                next = NULL;
        }
};

Employee *AddEmployee(unordered_map<string, int> &department_count)
{

        string name, designation, department;
        int employeeID;
        cout << "Enter EmploeeID: ";
        cin >> employeeID;
        cout << "Enter Name: ";
        cin >> name;
        cout << "Enter Department: ";
        cin >> department;
        cout << "Enter designation : ";
        cin >> designation;
        Employee *nw = new Employee(employeeID, name, designation, department);
        department_count[department]++;
        return nw;
}

Employee *deleteEmployee(Employee *first, unordered_map<string, int> &department_count)
{
        int ID;
        cout << "Enter Employee Id:";
        cin >> ID;
        Employee *temp = first, *prev = NULL;

        while (temp != NULL && temp->employeeID != ID)
        {
                prev = temp;
                temp = temp->next;
        }
        if (temp != NULL)
        {
                department_count[temp->department]--;

                if (temp != first)
                {
                        prev->next = temp->next;
                        cout << "Successfully deleted record of Employee " << temp->name << endl;
                }
                else
                {
                        first = first->next;
                }
                delete temp;
        }
        else
        {
                cout << "Entered ID Employee is not listed in Company\n";
        }
        return first;
}

void displayAll(Employee *first)
{
        Employee *temp = first;
        if (first == NULL)
        {
                cout << "We Don't have any emploee details\n";
                return;
        }
        while (temp != NULL)
        {
                cout << "Employee ID: " << temp->employeeID << endl;
                cout << "Employee name: " << temp->name << endl;
                cout << "Employee Designation: " << temp->designation << endl;
                cout << "Emplyee department : " << temp->department << endl;
                temp = temp->next;
                cout << endl;
        }
}

void displayDepartmentCount(unordered_map<string, int> &department_count)
{
        if (department_count.size() == 0)
        {
                cout << "NO Emploee Details Present\n";
                return;
        }

        for (auto department : department_count)
        {
                cout << department.first << ":" << department.second << endl;
        }
}

int main()
{
        // freopen("input.txt","r",stdin);
        int choice = -1;
        unordered_map<string, int> department_count;
        Employee *first = NULL, *last = NULL;

        while (1)
        {
                cout << "\n1.Add Employee\n2.Delete Emploee\n3.Display All Emploee Details\n4.Display count of Each department\n5.Exit\nEnter choice:\n";
                cin >> choice;

                switch (choice)
                {
                case 1:
                {

                        /* code */

                        Employee *nw = AddEmployee(department_count);
                        if (first == NULL)
                                first = last = nw;
                        else
                        {
                                last->next = nw;
                                last = nw;
                        }

                        break;
                }
                case 2:
                        first = deleteEmployee(first, department_count);
                        break;
                case 3:
                        displayAll(first);

                        break;

                case 4:
                        displayDepartmentCount(department_count);
                        break;
                case 5:
                        return 0;
                        break;

                default:
                        cout << "Enter Valid choice ";
                        break;
                }
        }
}


Related Solutions

implementing linked list using c++ Develop an algorithm to implement an employee list with employee ID,...
implementing linked list using c++ Develop an algorithm to implement an employee list with employee ID, name, designation and department using linked list and perform the following operations on the list. Add employee details based on department Remove employee details based on ID if found, otherwise display appropriate message Display employee details Count the number of employees in each department
List department name, employee id, and employee name for all employees in department name order. Repeat...
List department name, employee id, and employee name for all employees in department name order. Repeat for department #10 only. List the course ID, course name, section, instructor name, day, time, and room for all course sections. List the course ID, course name, section, student ID, and student name for CRN 1003. Display the list in ascending order of student last and first names. DROP TABLE registration; DROP TABLE sections; DROP TABLE courses; DROP TABLE students; DROP TABLE instructors; CREATE...
Employee ID First Name Last Name email Title Address Extension Department Department ID Hiring Date Department...
Employee ID First Name Last Name email Title Address Extension Department Department ID Hiring Date Department Phone # 0001 John Smith jsmith Accountant 1300 West st 5775 Accounting 2100 8/1998 407-366-5700 0002 Brian Miller badams Admin Assistant 1552 Palm dr 5367 Human resource 2300 4/1995 407-366-5300 0003 James Miller miller Inventory Manager 2713 Buck rd 5432 Production 2520 8/1998 407-366-5400 0004 John Jackson jackson_sam Sales Person 433 tree dr 5568 Sales 2102 6/1997 407-366-5500 0005 Robert Davis Davis Manager 713...
Develop an algorithm and implement a Preemptive Priority scheduling algorithm using C++ and using bubble sorting...
Develop an algorithm and implement a Preemptive Priority scheduling algorithm using C++ and using bubble sorting .Arrival time, burst time and priority values.The code should also display: (i) Gantt chart and determine the following: (ii) Determine the Turnaround time(TAT), waiting time(WT) of each process (iii) Determine the Average Waiting Time (AWT) and Average Turnaround Time (ATAT) of all processes. please write the comments
Implement an Employee class that includes data fields to hold the Employee’s ID number, first name,...
Implement an Employee class that includes data fields to hold the Employee’s ID number, first name, last name, and hourly pay rate (use of string datatype is not allowed). Create an array of five Employee objects. Input the data in the employee array. Write a searchById() function, that ask the user to enter an employee id, if its present, your program should display the employee record, if it isn’t there, simply print the message ”Employee with this ID doesn’t exist”....
Develop an algorithm and implement Optimal Page Replacement algorithm using C++. Determine the number of page...
Develop an algorithm and implement Optimal Page Replacement algorithm using C++. Determine the number of page faults and page hits by considering the Frame size=4, ReferenceString:2 4 6 7 8 2 4 9 13 9 2 7 2 6 1 4 9 2
java/netbeans 1.Design an abstract class Employee that stores: employee name, unique auto-generated id, hire year. Implement...
java/netbeans 1.Design an abstract class Employee that stores: employee name, unique auto-generated id, hire year. Implement any necessary methods in addition to: a.The toString and equals methods. The equals method should NOT compare the id. b.The copy constructor (should copy the same id too) c.An abstract method float getWeeklyCheckAmount() d.Implement the appropriate interface to be able to sort employee names in alphabetical order. Subclasses should NOT be allowed to override this implementation. 2.Design an abstract class HourlyWorker that extends Employee...
The system will accept the employee ID, the employee name and his/her gross salary.
The system will accept the employee ID, the employee name and his/her gross salary.Based on the gross salary provided, if it is equal to or greater than OMR 2500, the system should apply a tax rate of 6% when calculating the income tax otherwise a tax rate of 4% should be applied when calculating.calculate the income tax and the net salary,If (gross salary > = 2500)          Tax rate = 6%Else     Tax rate = 4%Income tax = Net salary = 
Develop an algorithm and implement Multilevel Queuing scheduling using C++.and using bubble sorting. Consider a set...
Develop an algorithm and implement Multilevel Queuing scheduling using C++.and using bubble sorting. Consider a set of user and system processes and determine (i) turnaround time (ii) waiting time of each process (iii) Average Waiting Time (AWT) and (iv) Average Turnaround Time (ATAT) of all processes. please write comment
Using UML, design a class that allows you to store and print employee information: name, id,...
Using UML, design a class that allows you to store and print employee information: name, id, and hourly_salary. Include the appropriate mutator and accessor methods. Write the code to create the class. Write a test program that instantiates an employee object. After the object is created write the code to give the employee a 3% raise. (IN PYTHON)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT