Statement of the Assignment:
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(…)
#include<iostream>
#include<string>
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[3];
	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<<endl;
		cout<<"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<<endl;
		cout<<"The employee with the following information has been added to the system:"<<endl;
		cout<<"First Name     Last Name     Personal ID     Salary per year (Rupees)"<<endl;
		cout<<"---------    -----------   -------------   -----------------------------";
		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\nID of Employee to Remove : ";
		cin>>t_id;
		cout<<"\nDo you really want to delete employee (Y/y , N/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());
					}
					i--;
				}
			}
		}
		cout<<"\nThe employee with the following information has been added to the system:"<<endl;
		cout<<"First Name     Last Name     Personal ID     Salary per year (Rupees)"<<endl;
		cout<<"---------    -----------   -------------   -----------------------------";
		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\nEnter an ID of employee to modify data = ";
		cin>>t_id;
		do{
			cout<<"\n\n 1. First Name";
			cout<<"\n 2. Last Name";
			cout<<"\n 3. Salary";
			cout<<"\n\nPlease enter the related number of field which you would like to update : ";
			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<<"\nDo you want to update another field (Y/y , N/n): ";
			cin>>choice;
		}while(choice == 'Y' || choice == 'y');
		cout<<"\nThe employee with the following information has been added to the system:";
		cout<<"\nFirst 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()
{
	cout<<"Welcome to www.learnwithismail.com"<<endl;
	cout<<"WhatsApp: 03017999306"<<endl;
	cout<<"***************************************************************************"<<endl;
	cout<<"Welcome to Human Resource Management (HRM) Software of Company XYZ. To do specific task please choose one of the following commands."<<endl<<endl<<endl;
	HRM obj;
	int choice;
	char x;
	p:
	cout<<"\n\n\t1. Add New Employee"<<endl;
	cout<<"\t2. Delete Employee Information"<<endl;
	cout<<"\t3. Update Employee Information"<<endl;
	cout<<"\t4. Quit"<<endl<<endl;
	cout<<"\tSelect 1 to 4 Options = ";
	cin>>choice;
	switch(choice)
	{
		case 1:
			cout<<endl;
			cout<<"Enter the information of the new employee";
			do{
				obj.AddPerson();
				cout<<"\n\ndo u want to add another employee (Y/y , N/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;
	return(0);
}

Leave a Reply

Your email address will not be published. Required fields are marked *