Details of this Paper

C++Define an Employee class

Description

solution


Question

Using C++ program language;Define an Employee class. Add the following private date members to the class: string status, int dependents. Status represents the marital status of the employee and should be set to either ?m? or ?s?. Add mutator/set and accessor/get methods for each of the new private data members. You must also revise the class constructors and the print method in the class to display all private data members.;Include a public method ?taxDeduction()? that should inspect the weeklyPay of the employee object and then based on the number of dependents and marital status return the tax deduction from a weekly pay based on the following table;Dependents;M;% tax deduction;S;%tax deduction;Less than or equal to 2;20%;25%;3;15%;20%;4;10%;15%;Greater than or equal to 5;8%;10%;Write a main function to test the class Employee. Create an object of the type Employee and call it myE then print the object and display the tax deduction from the weekly pay.;Add the following to your main function;Create two Employee pointer variables ptr1 and ptr2 and set them to NULL.;Make ptr1 point to the Employee myE created in part 3.;Dynamically allocated an Employee object and make ptr2 point to it.;Use the two pointers to call the print method of the object they point to.;Use ptr1 to change the value of the ?dependents? of the myE;Now make ptr2 point to myE. How many pointers are pointing to the Employee object myE? What happened to the dynamically created object that ptr2 was pointing to? What were you supposed to do before making ptr2 point to myE?

 

Paper#64073 | Written in 18-Jul-2015

Price : $27
SiteLock