Answer to Question #276012 in C++ for Asim

Question #276012

There is only one kind of manager in the EMPMULT program in inheritance chapter. Any serious


company has executives as well as managers. From the manager class derive a class


called executive. (We’ll assume an executive is a high-end kind of manager.) The addi￾tional data in the executive class will be the size of the employee’s yearly bonus and the


number of shares of company stock held in his or her stock-option plan. Add the appropriate


member functions so these data items can be input and displayed along with the other


manager data.

1
Expert's answer
2021-12-07T09:57:04-0500
#include <iostream>
#include <iomanip>
using namespace std;
class Manager
{
public:
    string name;
    int shares, ID;
    float bonus = 30000;
    void getData()
    {
        cout << "Enter manager ID" << endl;
        cin >> ID;
        cout << "Enter manager name" << endl;
        cin >> name;
        cout << "Enter manager number of shares" << endl;
        cin >> shares;
    }
    void displayData()
    {
        cout << ID << setw(10) << name << setw(10) << shares << setw(10) << bonus << endl;
    }
};
class executive : public Manager
{
public:
    void getData()
    {
        cout << "Enter execitive ID" << endl;
        cin >> ID;
        cout << "Enter execitive name" << endl;
        cin >> name;
        cout << "Enter execitive number of shares" << endl;
        cin >> shares;
    }
    void displayData()
    {
        cout << ID << setw(10) << name << setw(10) << shares << setw(10) << bonus << endl;
    }
};


int main()
{
    Manager m;
    m.getData();
    m.displayData();
    executive e;
    e.getData();
    e.displayData();
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment