C Program Using Visual Studio Program Requirements Create a

C++ Program Using Visual Studio

Program Requirements:

Create a class (named Employee). Each employee will have four data members: (i) Name of string type, (ii) Emp_ID (Employee ID) of integer type, (iii) Salary (annual salary) of Integer type, (iv) Retirement_cont (Annual Retirement Contribution) of double type. The member data members should be private.

It will have the following public member functions:

Constructor with following parameters:
A pointer to a string to initialize the Name of the employee
Integer to initialize the Emp_ID
Integer to initialize Salary

The Retirement_cont will be initialized as 6% of the Salary

DisplayEmp:
Output the Name, Employee ID, Salary and Retirement Contributions in separate lines
Output monthly gross salary of the employee by dividing Salary by 12
Output net Salary of the employee by subtracting retirement contribution from gross salary

GetSalary:
Returns the Salary of the Employee

GetRet:
Returns the Retirement contribution of the Employee


Test your class by creating five different employee objects for a small business in the main function.

Output Total Salary and Retirement contributions of the Employees.

Solution

Here is the solution...

#include <iostream>

#include<conio.h>
#include<string>
using namespace std;

// Class Declaration
class Employee
{
//Access - Specifier
private:

//Varibale Declaration
string name;
int Emp_ID;
int Salary;
double retirement_cont;
public:
Employee();
Employee(string emp_name,int emp_id,int sal,double ret_count);
int getSal(void);
double getRet(void);
void DisplayEmp(void);
  
};


Employee::Employee(string emp_name,int emp_id,int salary,double ret_cont=0 ) {
name=emp_name;
Emp_ID=emp_id;
Salary=salary;
retirement_cont=(0.06)*salary;
  
}

int Employee::getSal(void){
return Salary;
}

double Employee::getRet(void){
return retirement_cont ;
}

void Employee::DisplayEmp(void){
cout<<\"-------------Displaying Employee Information-------\" << endl;
cout << \"Employee Name: \" << name << endl;
cout << \"Employee ID: \" << Emp_ID << endl;
cout << \"Employee Salary: \" << getSal() << endl;
cout << \"Employee Retirement Contributions: \" << getRet() << endl;
cout << \"monthly gross salary of the employee: \" << getSal()/12 << endl;
cout << \"Net Salary of the employee: \" << getSal()-getRet() << endl;
cout<<\"--------------------\" << endl;

}


//Main Function
int main()
{
// Object Creation For Class
Employee obj1=Employee(\"alex\",111,12000);
cout << \"Employee Salary: \" << obj1.getSal() << endl;
cout << \"Employee Retirement Contributions: \" << obj1.getRet() << endl;
obj1.DisplayEmp();
Employee obj2=Employee(\"brain\",112,100000);
cout << \"Employee Salary: \" << obj2.getSal() << endl;
cout << \"Employee Retirement Contributions: \" << obj2.getRet() << endl;
obj2.DisplayEmp();
Employee obj3=Employee(\"catia\",111,12000);
cout << \"Employee Salary: \" << obj3.getSal() << endl;
cout << \"Employee Retirement Contributions: \" << obj3.getRet() << endl;
obj3.DisplayEmp();
Employee obj4=Employee(\"brain\",114,40000);
cout << \"Employee Salary: \" << obj4.getSal() << endl;
cout << \"Employee Retirement Contributions: \" << obj4.getRet() << endl;
obj4.DisplayEmp();
Employee obj5=Employee(\"ela\",115,15630
);
cout << \"Employee Salary: \" << obj5.getSal() << endl;
cout << \"Employee Retirement Contributions: \" << obj5.getRet() << endl;
obj5.DisplayEmp();
  
}

C++ Program Using Visual Studio Program Requirements: Create a class (named Employee). Each employee will have four data members: (i) Name of string type, (ii)
C++ Program Using Visual Studio Program Requirements: Create a class (named Employee). Each employee will have four data members: (i) Name of string type, (ii)

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site