Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are required to design a system for assigning different projects to different employees of a company. Each project has a title, cost, and duration

You are required to design a system for assigning different projects to different employees of a company. Each project has a title, cost, and duration in months.

Consider the following class definition of Project:

class Project

{

protected:

string title;

float cost;

int duration;

public:

Project(string="",int=0);

float calc_cost();

};

Project::Project(string t,int d1)

{

title=t;

duration=d1;

cost=0;}

float Project::calc_cost()

{cost=1000*duration;

return cost;

}

There are two types of projects in a company: Team Project and individual project. We need to store total number of employees working on Team Project. For an individual project, no extra information is required. Cost of Team project is calculated by using formula: cost = No. of employees x duration*1000 + 10,000. Cost of Individual Project is cost = duration*1000 + 10,000. Use C++ Inheritance concept and write implementation of team project and individual project. Write constructor for both classes and function float calc_cost() for both classes. This function should calculate cost and return its value. Use the space given on next page to write code.

Now consider following class definition of an Employee. This class stores id, salary and type of an employee. An employee can be commissioned employee or a part-time employee. For a commissioned employee, we set the type to 'c' and for part-time employee we set the type to 'p'. Every employee works on a project. Commissioned employee can work on Team Project only and part-time employee works only on an individual project.

  • Implement AssignProject function for this class. This function should assign a new Team or individual project to an employee based on type of employee. For any type of project, ask user to enter required details.
  • implement a function to calculate Salary of an employee. Employee is paid on basis of the project he/she is working on. Employee's salary is 20 percent of the cost of the project. This function should return the calculated salary.

You are not allowed to implement any other member function.

class Employee{

private:

int ID;

Project *p;

float salary;

char Type;

public:

Employee(int=0, char='c');

void AssignProject();

float CalcSalary();

};

Sample Main

int main()

{Employee E1(1,'c');

E1.AssignProject();

cout<

return 0; }

output

50000

The main is for a Commissioned employee who works on a team project with duration = 20 days, and number of members=12

Employee::Employee(int id_val, char typeVal){

ID=id_val;

p=0;

Type=typeVal;

}

Implement these:

Class TeamProject [5 marks]

{

};

Class IndividualProject [5 marks]

{

};

Constructor of Class TeamProject[3 Marks]

Constructor of Class IndividualProject [2 Marks]

Calc_cost() for class TeamProject [2.5 Marks]

Calc_cost() for Class IndividualProject [2.5 Marks]

Calc_Salary() for class Employee: [4Marks]

void Employee::AssignProject() [6 marks]

{

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions

Question

=+b. Who are the governors of the board?

Answered: 1 week ago