I am having a real hard time with this can alife saver help with this Create a c
ID: 3618836 • Letter: I
Question
I am having a real hard time with this can alife saver help with this
Create
a class called Employee that includes three pieces ofinformation as
data membersa first name (type string), a last name(type
string) and a monthly salary (type int). [Note:In subsequent chapters, we'll use numbers that
contain decimal points (e.g., 2.75)called floating-point valuestorepresent
dollar amounts.] Your class should have a constructor thatinitializes the three
data members. Provide a set and a get function for each datamember. If the monthly
salary is not positive, set it to 0. Write a test programthat
demonstrates class Employee's capabilities. Create two
Employee objects and display each object's yearly salary.Then give each Employee a 10
percent raise and display each Employee's yearly salaryagain.
Explanation / Answer
Employee.CPP #include using namespace std; class Employee //Sample Class for the C++ Tutorial { private: string firstName;//Data member string lastName;// Data member doublemonthlySalary; // Data member public: Employee(stringfname, string lname, double msalary) //Constructor for the C++tutorial { this.setFirstName(fname); this.setLastName(lname); this.setMonthlySalary(msalary); } ~Employee() //destructor forthe C++ Tutorial { } voidsetFirstName(string fname) { firstName = fname; } stringgetFirstName(void) { return firstName; } voidsetLastName(string lname) { lastName = lname; } stringgetLastName(void) { return lastName; } voidsetMonthlySalary(double msalary) { if(msalary >= 0) this.setMonthlySalary(msalary); else coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.