Question: I am having issues I am using the code below but I am getting to many errors please help! With Visual Studio Please. Create a

I am having issues I am using the code below but I am getting to many errors please help! With Visual Studio Please.

Create a class called Employee that includes three pieces of information as data members

A first name (type string), a last name (type string) and a monthly salary (type floating point).

Your class should have a constructor that initializes the three data members.

Provide a set and get functions for each data member.

Create two Employee objects and display each object's yearly salary.

Then give each Employee a 10% raise and display each Employee's yearly salary again

/*

* Program in C++

*/

#include

#include

using namespace std;

class Employee

{

private:

string firstName, lastName;

float monthlySalary;

public:

/*Constructor to initialize all three data members*/

Employee(string fName, string lName, float sal) : firstName(fName), lastName(lName), monthlySalary(sal){}

/*Get methods for each data members to get values of each data members*/

string getFirstName() { return firstName; }

string getLastName() { return lastName; }

float getMonthlySalary() { return monthlySalary; }

/*Set methods for each data members to change values of each data members*/

void setFirstName(string fName) { firstName = fName; }

void setLastName(string lName) { lastName = lName; }

void setMonthlySalary(float sal) { monthlySalary = sal; }

};

int main()

{

/*Creating two Employee objects*/

Employee e1("Tony", "Stark", 25000);

Employee e2("Bill", "Gates", 30000);

/*Printing yearly salary of both employees*/

cout << "Yearly salary of Mr. " << e1.getFirstName() << " " << e1.getLastName() << ": $" << e1.getMonthlySalary() * 12 << endl;

cout << "Yearly salary of Mr. " << e2.getFirstName() << " " << e2.getLastName() << ": $" << e2.getMonthlySalary() * 12 << endl;

/*Raising 10% salary of both employees*/

cout << "Giving both employees a 10% raise..." << endl;

float newSalary1 = e1.getMonthlySalary() + e1.getMonthlySalary() * 10 / 100;//New salary for employee 1

float newSalary2 = e2.getMonthlySalary() + e2.getMonthlySalary() * 10 / 100;//New salary for employee 2

/*Updating salary of both employees*/

e1.setMonthlySalary(newSalary1);

e2.setMonthlySalary(newSalary2);

/*Printing yearly salary of both employees*/

cout << "Yearly salary of Mr. " << e1.getFirstName() << " " << e1.getLastName() << ": $" << e1.getMonthlySalary() * 12 << endl;

cout << "Yearly salary of Mr. " << e2.getFirstName() << " " << e2.getLastName() << ": $" << e2.getMonthlySalary() * 12 << endl;

system("pause");//To pause console screen;

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!