Write a C++ program that uses the class SalariedEmployee. Your program is to def
ID: 3683280 • Letter: W
Question
Write a C++ program that uses the class SalariedEmployee. Your program is to define a derived class called Administrator, which is to be derived from SalariedEmployee. You are to supply the following data and function members in the Administrator class: A member variable of type string that contains the administrator's title(e.g., Director, Vice President). A member variable of type string that contains the company area of responsibility(e.g., Production, Accounting). A member variable of type string that contains the name of the administrator's immediate supervisor. A protect member variable of type double that holds the administrator's annual salary(if the salary is for an administrator, the salary is kept in this variable, not the salary variable in the SalariedEmployee class). A member function that returns each of the variables above. A member function which sets each of the variables above. A member function called print, which outputs the object's data to the screen. The SalariedEmployee class is to contain the following: Member variables containing the following data: name, ssn, netPay, wagePay, hours, department(the variable wagePay and hours are to be set to private). A member function that returs each of the variables above. A member function which sets each of the variables above.
Explanation / Answer
#include<iostream>
#include<string>
using namespace std;
class SalariedEmployee
{
public:
string name, ssn, department;
double netPay, wagePay, hours;
string get_name()
{
return name;
}
string get_ssn()
{
return ssn;
}
string get_depa()
{
return department;
}
double get_net()
{
return netPay;
}
double get_wage()
{
return wagePay;
}
double get_hr()
{
return hours;
}
void set_name(string t)
{
strcpy(name,t);
}
void set_ssn(string r)
{
strcpy(ssn,r);
}
void set_depa(string s)
{
strcpy(department,s);
}
void set_netP(double t)
{
netPay=t;
}
void set_wag(double t)
{
nwagePay=t;
}
void set_hr(double t)
{
hours=t;
}
};
class Administrator : SalariedEmployee
{
public:
string title, respons, superv;
protected:
double ann_sal;
string get_tit()
{
return title;
}
string get_res()
{
return respons;
}
string get_sup()
{
return superv;
}
double get_sal()
{
return ann_sal;
}
void set_tit(string t)
{
strcpy(title,t);
}
void set_res(string r)
{
strcpy(respons,r);
}
void set_sup(string s)
{
strcpy(superv,s);
}
void set_sal(double t)
{
ann_sal=t;
}
};
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.