Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can you please write out this program for me. This is one of my three assignment

ID: 3543563 • Letter: C

Question

Can you please write out this program for me. This is one of my three assignments that I need to complete and the other two are very similar to this one. If I have a correct solution from this one I know that I will be able to figure out the other two. Thank you for your time!

______________________________________________________________________________________________

Write the class definition for a class named Employee. The class should
include data members for an employee object's name and salary (the salary will
be an integer). The class should contain two member functions: the constructor
and a function that allows a program to assign values to the data members. Add
two member functions to the employee class. One member function should allow any
program using an employee object to view the contents of the salary data member.
The other member function should allow the program to view the contents of the
employee name data member. (Hint: have the member functions simply return the
contents of the appropriate data member).

Add another member function to the class. This function should calculate an
employee object's new salary, based on a raise percentage, provided by the
program (main function). Before calculating the raise, the member function
should verify that the raise percentage is greater or equal to zero. If the
raise percentage is less then zero, the member function should display an error
message.

Write main function that will create an array of employee objects, assign
values to the objects, display the names and current salaries for all objects,
ask user for the raise percentage and then calculate and display new salaries
for all objects.

Explanation / Answer

#include<iostream>

#include<string>

using namespace std;


class Employee

{

string name;

int salary;

public:

//constructor

Employee()

{

name="";

salary=0;

}

//to assign value to data member of object

void assignValues()

{

cout<<"Enter Employee name:";

cin>>name;

cout<<"Enter Employee Salary:";

cin>>salary;

}

//to get salary of employee

int getSalary()

{

return salary;

}

//to get name of employee

string getName()

{

return name;

}

//function to calculate new salary based on raise

void calculateNewSalary(int raise)

{

if(raise>=0)

{

salary = ((100+raise)*salary)/100;

}

else

{

cout<<"raise percentage can not be negative. Please try again. ";

}

}

};


int main()

{

//construct an array of Employee

Employee emp[5];

//assign valuses to object

for(int i=0;i<5;i++)

{

cout<<"For Employee no "<<i+1<<endl;

emp[i].assignValues();

}

//display name and salary of emp

for(int i=0;i<5;i++)

{

cout<<"Employee Number "<<i+1<<endl;

cout<<"Name :"<<emp[i].getName()<<endl;

cout<<"Salary:"<<emp[i].getSalary()<<endl;

}

//raise percentage

for(int i=0;i<5;i++)

{ int raise;

cout<<"Enter Raise for Employee name "<<emp[i].getName()<<endl;

cin>>raise;

emp[i].calculateNewSalary(raise);

}

//show new salaries

for(int i=0;i<5;i++)

{

cout<<"Employee Number "<<i+1<<endl;

cout<<"Name :"<<emp[i].getName()<<endl;

cout<<"Salary:"<<emp[i].getSalary()<<endl;

}

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote