0

Employee Management System in C++/ CPP

Employee Management System

PROBLEM STATEMENT:

You are hired as an Application developer for a company called XYZ to facilitate the Human resource Management Department (HRM) to keep employee record. You are requested to write a program for HRM department to keep record of maximum 10 employees. Following is a menu and step by step guidance.

Menu: Welcome to Human Resource Management (HRM) Software of Company XYZ.

To do specific task please choose one of the following commands.

1. Add new employee

2. Delete employee information

3. Update employee information

4. Quit

Please enter the related number of your requested command?

Consider the following part of Person class which is containing some data members in it. Class Person should include following private fields:

• FirstName (String)

• LastName (String)

• PersonalID (Integer)

• Salary (Double)

Class Person should have public member functions for setting and getting the private fields. Member functions should have the following naming style:

• set_FieldName()

• get_FieldName() The field “PersonalID” of class Person should be unique and auto-increment with the initial value of 8248001 for the first employee. It means that user should not enter the value for “personalID”. Class HRM should include following private fields:

• Array of employees with the type Person (Private)

• The actual number of employees which is stored in Array of employees(private) Class HRM should include following public member functions:

• AddPerson()

• DeletePerson(…)

• UpdatePerson(…)

CODE:

#include<iostream>
#include<conio.h>
using namespace std;
int id=1234567,i=0;
class Person
{
	private:
		string FirstName;
		string LastName;
		int PersonalId;
		double Salary;
	public:
		void set_FirstName(string fn);
		void set_LastName(string ln);
		void set_PersonalId(int z);
		void set_Salary(double sal);
		string get_FirstName();
		string get_LastName();
		int get_PersonalId();
		double get_Salary();
		
};
class HRM
{
	private:
		Person p[15];
	public:
		void AddPerson();
		void DeletePerson();
		void UpdatePerson();	
};
	void Person::set_FirstName(string fn)
	{
		FirstName = fn;
	}
	void Person::set_LastName(string ln)
	{
		LastName = ln;
	}
	void Person::set_PersonalId(int z)
	{
		PersonalId = z;
	}
	void Person::set_Salary(double sal)
	{
		Salary = sal;
	}
	string Person::get_FirstName()
	{
		return FirstName;
	}
	string Person::get_LastName()
	{
		return LastName;
	}
	int Person::get_PersonalId()
	{
		return PersonalId;
	}
	double Person::get_Salary()
	{
		return Salary;
	}
	void HRM::AddPerson()
	{
		string fn,ln;
		double sal;
		cout<<"\n\n First Name : ";
		cin>>fn;
		p[i].set_FirstName(fn);
		cout<<" Last Name : ";
		cin>>ln;
		p[i].set_LastName(ln);
		p[i].set_PersonalId(id);
		id++;
		cout<<" How much is his/her Salary? =";
		cin>>sal;
		p[i].set_Salary(sal);
		i++;
		cout<<"\n\n New employee information added in the system";
		cout<<"\n\n First Name     Last Name     Personal ID     Salary per year (Rupees)";
		cout<<"\n -----------  ------------- ---------------    -----------------------";
		for(int a=0;a<i;a++)
		{
			cout<<"\n "<<p[a].get_FirstName()<<"          "<<p[a].get_LastName()<<"          "<<p[a].get_PersonalId()<<"               "<<p[a].get_Salary();
		}
	}
	void HRM::DeletePerson()
	{
		int t_id;
		char x;
		cout<<"\n\n ID of Employee to Remove : ";
		cin>>t_id;
		cout<<"\n Do you want to really delete employee (Y,N) : ";
		cin>>x;
		if(x == 'Y' || x == 'y')
		{
			for(int a=0;a<i;a++)
			{
				if(p[a].get_PersonalId() == t_id)
				{
					for(int k=a;k<i;k++)
					{
						p[k].set_FirstName(p[k+1].get_FirstName());
						p[k].set_LastName(p[k+1].get_LastName());
						p[k].set_PersonalId(p[k+1].get_PersonalId());
						p[k].set_Salary(p[k+1].get_Salary());
					}
					cout<<"\n\n Delete employee information from the system";
					i--;
				}
			}
		}
		cout<<"\n\n First Name     Last Name     Personal ID     Salary per year (Rupees)";
		cout<<"\n -----------  ------------- ---------------    -----------------------";
		for(int a=0;a<i;a++)
		{
			cout<<"\n "<<p[a].get_FirstName()<<"          "<<p[a].get_LastName()<<"          "<<p[a].get_PersonalId()<<"               "<<p[a].get_Salary();
		}
	}
	void HRM::UpdatePerson()
	{
		int t_id,x;
		double sal;
		char choice;
		string fn,ln;
		cout<<"\n\n Employee ID for modify information : ";
		cin>>t_id;
		do{
			cout<<"\n\n 1. First Name";
			cout<<"\n 2. Last Name";
			cout<<"\n 3. Salary";
			cout<<"\n\n Number of Field for modify : ";
			cin>>x;
			for(int a=0;a<i;a++)
			{
				if(p[a].get_PersonalId() == t_id)
				{
					if(x == 1)
					{
						cout<<"\n First Name : ";
						cin>>fn;
						p[a].set_FirstName(fn);
					}
					else if(x == 2)
					{
						cout<<"\n Last Name : ";
						cin>>ln;
						p[a].set_LastName(ln);
					}
					else if(x == 3)
					{
						cout<<"\n Salary : ";
						cin>>sal;
						p[a].set_Salary(sal);
					}
					cout<<"\n\n Modify employee information from the system";
				}
			}
			cout<<"\n\n Do you want modify another field (Y,N) : ";
			cin>>choice;
		}while(choice == 'Y' || choice == 'y');
		cout<<"\n\n First Name     Last Name     Personal ID     Salary per year (Rupees)";
		cout<<"\n -----------  ------------- ---------------    -----------------------";
		for(int a=0;a<i;a++)
		{
			cout<<"\n "<<p[a].get_FirstName()<<"          "<<p[a].get_LastName()<<"          "<<p[a].get_PersonalId()<<"               "<<p[a].get_Salary();
		}
	}
main()
{
	HRM obj;
	int choice;
	char x;
	p:
	cout<<"\n\n\t1. Add New Employee";
	cout<<"\n\t2. Delete Employee Information";
	cout<<"\n\t3. Update Employee Information";
	cout<<"\n\t4. Quit";
	cout<<"\n\n\tEnter Your Choice : ";
	cin>>choice;
	switch(choice)
	{
		case 1:
			cout<<"\n\n Enter the information of the new employee";
			do{
				obj.AddPerson();
				cout<<"\n\n Do you want to add another employee (Y,N) : ";
				cin>>x;
			}while(x == 'Y' || x == 'y');
			break;
		case 2:
			obj.DeletePerson();
			break;
		case 3:
			obj.UpdatePerson();
			break;
		case 4:
			exit(0);
		default:
			cout<<"\n\n\tInvalid Value...Please Try Again...";
	}
	goto p;
}

DEMO:

0

Assignment 2 Cs508 – Modern programming languages Semester Spring 2021

cs508 assignment 2 solution 2021

CODE:

START
	STRING = INPUT
	OUTPUT = "Please Enter a String: " STRING
	A1 = ('a' | 'e' | 'i' | 'o' | 'u' | 'A' | 'E' | 'I' | 'O' | 'U') . V
        B2 = ('b' | 'c' | 'd' | 'f' | 'g' | 'j' | 'k' | 'l' | 'm' | 'n' | 'p' | 'q' | 'r' | 's' | 't' | 'v' | 'w' | 'x' | 'y' | 'z' | 'B' | 'C' | 'D' | 'F' | 'G' | 'H' | 'J' | 'K' | 'L' | 'M' | 'N' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'V' | 'W' | 'X' | 'Y' | 'Z') . C
	
	STR1 = ''
	STR2 = ''

	CNTR1 = 0
	CNTR2 = 0

ALABEL STRING A1 = :F(BLABEL)
	STR1 = STR1 '' V
	CNTR1 = CNTR1 + 1 :S(ALABEL)

BLABEL STRING B2 = :F(RESULT)
	STR2 = STR2 '' C
	CNTR2 = CNTR2 + 1 :S(ALABEL)

RESULT OUTPUT = 'FOUND' CNTR1 'VOWELS' STR1
	OUTPUT = 'FOUND' CNTR2 'Cons' STR2
END

DEMO:

TAGS:

virtual university,cs508 assignment solution,assignment solution,assignment solution spring 2021,cs508 assignment 1 solution 2021,cs508 solution,cs408 assignment 1 solution 2021,vu assignment,cs508 assignment no 3,cs302 assignment 2 solution 2021,cs607 assignment 2 solution 2021,cs508 assignment 3 solution 2020,cs508 assignment no 3 solution fall 2020,cs508 assignment no 3 solution,cs508 assignment 1,cs411 assignment 2 solution 2021,cs508 assignment no 1 solution spring 2021,assignment

0

CS201 Assignment 2 Solution Spring 2021

Problem Statement:

Write a program that stores matrix 2 * 2 and find transpose, adjoint, and determination using functions.

CODE:

#include <iostream>

#include <conio.h>

using namespace std;
int ShowMatrix() {
  int row = 2, column = 2;
  int matrix[2][2] = {
    {
      8,
      -4
    },
    {
      -6,
      2
    }
  };
  cout << "The matrix is:" << endl;
  for (int i = 0; i < row; ++i) {
    for (int j = 0; j < column; ++j)
      cout << matrix[i][j] << " ";
    cout << endl;
  }
}
int showTranspose() {
  int transpose[2][2], row = 2, column = 2, i, j;
  int matrix[2][2] = {
    {
      8,
      -4
    },
    {
      -6,
      2
    }
  };
  cout << endl;
  for (i = 0; i < row; ++i)
    for (j = 0; j < column; ++j) {
      transpose[j][i] = matrix[i][j];
    }
  cout << "The transpose of the matrix is:" << endl;
  for (i = 0; i < column; ++i) {
    for (j = 0; j < row; ++j)
      cout << transpose[i][j] << " ";
    cout << endl;
  }
}
int calculateDeterminant() {
  int determMatrix[2][2], determinant;
  int matrix[2][2] = {
    {
      8,
      -4
    },
    {
      -6,
      2
    }
  };
  determinant = ((matrix[0][0] * matrix[1][1]) -
    (matrix[0][1] * matrix[1][0]));
  cout << "\nThe Determinant of 2 * 2 Matrix = " << determinant;
}
int showAdjoint() {
  int ch, A2[2][2] = {
    {
      8,
      -4
    },
    {
      -6,
      2
    }
  }, AD2[2][2], C2[2][2];
  //Calculating cofactors of a matrix of order 2x2
  C2[0][0] = A2[1][1];
  C2[0][1] = -A2[1][0];
  C2[1][0] = -A2[0][1];
  C2[1][1] = A2[0][0];
  //calculating adjoint of the matrix of order 2x2
  AD2[0][0] = C2[0][0];
  AD2[0][1] = C2[1][0];
  AD2[1][0] = C2[0][1];
  AD2[1][1] = C2[1][1];
  cout << "\n\nAdjoint of A is :- \n\n";
  cout << "|\t" << AD2[0][0] << "\t" << AD2[0][1] << "\t|\n|\t" << AD2[1][0] << "\t" << AD2[1][1] << "\t|\n";
}
int main() {
  int choice = 0;
  cout << "Enter your choice " << endl;
  cout << "Press 1 to display the matrix and its transpose" << endl;
  cout << "Press 2 to find adjoint and determinant of the matrix" << endl;
  cout << "Press any other key to exit.";
  cin >> choice;
  if (choice == 1) {
    ShowMatrix();
    showTranspose();
  } else if (choice == 2) {
    showAdjoint();
    calculateDeterminant();
  } else
    system("pause");
}

DEMO: