{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Class employee string firstname string lastname char

Info iconThis preview shows pages 4–7. Sign up to view the full content.

View Full Document Right Arrow Icon
class Employee { string firstName; string lastName; char gender; int dependents; double salary; public : Employee() //default constructor { firstName = "" ; lastName = "" ; gender = 'N' ; dependents = 0; salary = 50000; } // 5 argument-constructor
Background image of page 4

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CIS-247C OOP/C++ H2 Solutions 3/18/2012 Employee(string firstName, string lastName, char gender, int dependents, double salary) { // use the THIS keyword to identify the class attributes this ->lastName = lastName; this ->firstName = firstName; this ->gender = gender; this ->dependents = dependents; this ->salary = salary; } // setter (also called mutator) functions void setLastName(string name) { lastName = name; } void setFirstName(string name) { firstName = name; } void setGender( char gen) { switch (gen) { case 'f' : case 'F' : case 'M' : case 'm' : gender = gen; break ; default : gender = 'N' ; // 'N' not defined } } void setDependents( int dep) { dependents = dep; } void setSalary( double salary) { this ->salary = salary; } // getter (also called accessor) functions string getLastName() { return lastName; } string getFirstName() { return firstName; } char getGender() { return gender; } int getDependents() { return dependents; } double getSalary() { return salary; } void getEmployee() { cout << "Employee Information\n" ; cout << "Name: \t\t" << firstName << " " ; cout << lastName<< "\n" ; cout << "Gender:\t\t" << gender << "\n" ; cout << "Dependents: \t" << dependents << "\n" ; cout << "Annual Salary:\t" ; cout << setprecision(2) << showpoint << fixed; cout << salary << "\n" ; cout << "Weekly Salary:\t" ; cout << setprecision(2) << showpoint << fixed; cout << calculatePay() << endl; } // Other functions double calculatePay() { return salary/12.0; } };
Background image of page 5
CIS-247C OOP/C++ H2 Solutions 3/18/2012 //************************************************************** ******** // The "main" and the other functions
Background image of page 6

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page4 / 7

class Employee string firstName string lastName char gender...

This preview shows document pages 4 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon bookmark
Ask a homework question - tutors are online