Knowee
Questions
Features
Study Tools

Suppose you are tasked with designing a program to model different types of employees in a company. Define three classes: Employee, Manager, and Developer, each with specific attributes and functionalities. 1.Employee Class: •Attributes: name (string), employeeId (integer), and salary (double). •Implement a constructor to initialize the name, employeeId, and salary attributes. •Implement a member function displayDetails() to display the name, employee ID, and salary of the employee. 2.Manager Class (Derived from Employee): •Attributes: department (string). •Implement a constructor to initialize the name, employeeId, salary, and department attributes. •Implement a member function displayDetails() to display the name, employee ID, salary, and department of the manager. 3.Developer Class (Derived from Employee): •Attributes: programmingLanguage (string). •Implement a constructor to initialize the name, employeeId, salary, and programmingLanguage attributes. •Implement a member function displayDetails() to display the name, employee ID, salary, and programming language of the developer. INPUT/OUTPUT EXAMPLE: Enter employee name: JAHANGEER Enter employee ID: 1 Enter employee salary: $5000 Enter manager name: JOHN Enter manager ID: 2 Enter manager salary: $6000 Enter manager department: RANDD Enter developer name: KEATS Enter developer ID: 3 Enter developer salary: $4000 Enter developer programming language: C Employee Details: Name: JAHANGEER Employee ID: 1 Salary: $5000 Manager Details: Name: JOHN Employee ID: 2 Salary: $6000 Department: RANDD Developer Details: Name: KEATS Employee ID: 3 Salary: $4000 Programming Language: C<iostream>

Question

Suppose you are tasked with designing a program to model different types of employees in a company. Define three classes: Employee, Manager, and Developer, each with specific attributes and functionalities. 1.Employee Class: •Attributes: name (string), employeeId (integer), and salary (double). •Implement a constructor to initialize the name, employeeId, and salary attributes. •Implement a member function displayDetails() to display the name, employee ID, and salary of the employee. 2.Manager Class (Derived from Employee): •Attributes: department (string). •Implement a constructor to initialize the name, employeeId, salary, and department attributes. •Implement a member function displayDetails() to display the name, employee ID, salary, and department of the manager. 3.Developer Class (Derived from Employee): •Attributes: programmingLanguage (string). •Implement a constructor to initialize the name, employeeId, salary, and programmingLanguage attributes. •Implement a member function displayDetails() to display the name, employee ID, salary, and programming language of the developer.

INPUT/OUTPUT EXAMPLE: Enter employee name: JAHANGEER Enter employee ID: 1 Enter employee salary: 5000Entermanagername:JOHNEntermanagerID:2Entermanagersalary:5000 Enter manager name: JOHN Enter manager ID: 2 Enter manager salary: 6000 Enter manager department: RANDD Enter developer name: KEATS Enter developer ID: 3 Enter developer salary: $4000 Enter developer programming language: C

Employee Details: Name: JAHANGEER Employee ID: 1 Salary: $5000

Manager Details: Name: JOHN Employee ID: 2 Salary: $6000 Department: RANDD

Developer Details: Name: KEATS Employee ID: 3 Salary: $4000 Programming Language: C<iostream>

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is the code in C++:

#include<iostream>
#include<string>
using namespace std;

class Employee {
protected:
    string name;
    int employeeId;
    double salary;
public:
    Employee(string name, int employeeId, double salary) {
        this->name = name;
        this->employeeId = employeeId;
        this->salary = salary;
    }
    virtual void displayDetails() {
        cout << "Name: " << name << endl;
        cout << "Employee ID: " << employeeId << endl;
        cout << "Salary: $" << salary << endl;
    }
};

class Manager : public Employee {
private:
    string department;
public:
    Manager(string name, int employeeId, double salary, string department) : Employee(name, employeeId, salary) {
        this->department = department;
    }
    void displayDetails() override {
        Employee::displayDetails();
        cout << "Department: " << department << endl;
    }
};

class Developer : public Employee {
private:
    string programmingLanguage;
public:
    Developer(string name, int employeeId, double salary, string programmingLanguage) : Employee(name, employeeId, salary) {
        this->programmingLanguage = programmingLanguage;
    }
    void displayDetails() override {
        Employee::displayDetails();
        cout << "Programming Language: " << programmingLanguage << endl;
    }
};

int main() {
    Employee e("JAHANGEER", 1, 5000);
    Manager m("JOHN", 2, 6000, "RANDD");
    Developer d("KEATS", 3, 4000, "C");

    cout << "Employee Details:" << endl;
    e.displayDetails();
    cout << endl;

    cout << "Manager Details:" << endl;
    m.displayDetails();
    cout << endl;

    cout << "Developer Details:" << endl;
    d.displayDetails();
    cout << endl;

    return 0;
}

This code defines three classes: Employee, Manager, and Developer. The Manager and Developer classes are derived from the Employee class. Each class has a displayDetails() function to display the details of the employee, manager, or developer. The main() function creates an object of each class and calls their displayDetails() function to display their details.

This problem has been solved

Similar Questions

Q1. Create an Employee class with the relevant attributes and methods in addition of thefollowing specifications:  It contains a default constructor. It contains a parameterized constructor. It contains a copy constructor.Note: Each student should have different their own version and it is better to have morethe attributes and methods.Q2. Incorporate static attributes and static methods in the Employee class where required.note for chatgpt/bard : computer languages used for code is c#

You are tasked with developing a software system for managing different types of employees in a company. The company has three types of employees: full-time employees, part-time employees, and consultants. Each type of employee has different attributes and calculation methods for calculating their monthly salary.Full-time employees receive a fixed monthly salary.Part-time employees are paid based on the number of hours they work and rate per hour.Consultants are paid based on the number of hours they work and an hourly rate.Design a C++ program that utilizes runtime polymorphism to model this scenario. Create a base class Employee with virtual functions calculateSalary() and displayDetails(). Derive three classes FullTimeEmployee, PartTimeEmployee, and Consultant from Employee, each implementing its own version of calculateSalary() and displayDetails() based on the rules described above.Then, demonstrate the use of runtime polymorphism by creating an array of Employee pointers containing instances of full-time employees, part-time employees, and consultants. Populate the array with objects of each type and iterate over it, calling the calculateSalary() and displayDetails() functions for each employee. Input Format:Enter name of full-time employeeEnter monthly salaryEnter name of part-time employeeEnter hourly rateEnter hours workedEnter name of consultantEnter hourly rateEnter hours worked

C# simple and easy program Q1. Create an Employee class with the relevant attributes and methods in addition of thefollowing specifications:  It contains a default constructor. It contains a parameterized constructor. It contains a copy constructor.Q2. Incorporate static attributes and static methods in the Employee class where required.

Create a class employee with protected members:Name,age,degree,genderCreate a member function to read the details.  Create a derived class department by inheriting the employee class privately.Declare the protected members: department_name, designation.Create a member function to read the details of the department.Create a member function to display the details of employee class and department class.Create a derived class salary by inheriting the employee class privately with protected members: basic payCreate default constructor to read basic pay.Define a member function to calculate the gross pay. Gross_pay=basic_pay+DA+HRADA=30% of basic payHRA =12% of basic payCreate a member function to display the details of employee class and the grosspay.

You're tasked with designing an employee management system for a company. You've created a base class Employee with virtual functions calculateSalary() and displayDetails(). Now, you need to implement derived classes FullTimeEmployee and PartTimeEmployee. How would you utilize virtual functions to calculate the salary and display details for each type of employee?

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.