Answer to Question #335040 in C++ for yormi

Question #335040

Create the class Employee that has the following member data: employee id, employee name, gender, date of birth, address, contact number, date hired, employee type, position, and salary rate. Define all the accessors and mutators needed for the member data of this class. Test the class by creating an object in the main function and try changing or displaying the values of its member data through its accessors and mutators.


1
Expert's answer
2022-04-29T11:29:28-0400
#include <iostream>
#include <cstring>

using namespace std;
class employee
{
	int     emp_id;
	string  emp_name;
	string  emp_gerden;
	string  emp_DoB;
	string  emp_address;
	string  emp_phone;
	string  emp_DH;
	string  emp_type;
	string  emp_pos;
	double  emp_salary;
	
	public:
		void get_emp_details();
		void show_emp_details();
};

void employee :: get_emp_details()
{
	cout<<"\nEnter employee id: ";
	cin>>emp_id;
	cout<<"\nEnter employee name: ";
	cin>>emp_name;
	cout<<"\nEnter employee gerden: ";
	cin>>emp_gerden;
	cout<<"\nEnter employee Date of birth (MM/DD/YY): ";
	cin>>emp_DoB;
	cout<<"\nEnter employee address: ";
	cin>>emp_address;
	cout<<"\nEnter employee contact number: ";
	cin>>emp_phone;
	cout<<"\nEnter employee date hired (MM/DD/YY): ";
	cin>>emp_DH;
	cout<<"\nEnter employee type: ";
	cin>>emp_type;
	cout<<"\nEnter employee position : ";
	cin>>emp_pos;
	cout<<"\nEnter employee salary rate (USD): ";
	cin>>emp_salary;
}

void employee :: show_emp_details()
{
    cout<<"\n\n\n\n-------------------------------\n";
	cout<<"\n**** Details of  Employee ****";
	cout<<"\nEmployee Name         :  "<< emp_name;
	cout<<"\nEmployee id           : " << emp_id;
	cout<<"\nDate of birth         : " << emp_DoB;
	cout<<"\nAddress               : " << emp_address;
	cout<<"\nContact number        : " << emp_phone;
	cout<<"\nDate hired            : " << emp_DH;
	cout<<"\nEmployee position     : " << emp_pos;
	cout<<"\nEmployee salary rate  : " << emp_salary;
	cout<<"\n-------------------------------\n\n";
}

int main()
{
    employee emp;
    
    emp.get_emp_details();
    emp.show_emp_details();

    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS