Question: (a) Using the C++ programming language, create a class, Workerwhich stores the information for individual worker in a company. This class must have the following

 (a) Using the C++ programming language, create a class, Workerwhich storesthe information for individual worker in a company. This class must havethe following private member variables and functions. Implement the class and it's

(a) Using the C++ programming language, create a class, Workerwhich stores the information for individual worker in a company. This class must have the following private member variables and functions. Implement the class and it's members. i. Private members as follows: A string name to store the worker name - A float payPerHours to store the hourly salary rate in RM. [2 marks] ii. A parameterized constructor, which takes in two argument values for setting the member variables to these argument values. [2 marks] iii. Member functions as listed below Function prototype: void showWorkersInfo() displays the worker name and hourly rate. Function prototype; float getPayPerHour() return the hourly rate. [4 marks) Note: Write a complete C++ class based on the requirements above. You must define the member functions outside of the class. (b) Implement all the member functions for the class Company shown in Figure 3. The class store information about a list of workers hired. Company class has an array of Worker objects as member variable. Each object in the array store information about the worker hired by the company. Table 1 shows the detail explanation of the member's role. The member functions must be implemented so that the main() driver function in Figure 3 produce desired output shown in Figure 5. The allocated marks are shown as comment beside the function declaration // Class Company has class Worker (Composition) class Company Worker* W; int numWorkers=0; int maximumWorkers; public: Company (int maxNum ); // 2 marks int addWorkers (string workerName, float a_hourly_pay); //3 marks void listallworkers(); // 3 marks float calculateJobCost(int hours); // 4 marks }; Figure 3 Company Class Members W numWorkers maximumWorkers Company (int maxNum) Responsibility Pointer that represent an array of Worker objects Number of workers currently employed Maximum number of workers that can be employed Constructor that initialize the object's maximumWorkers based on maxNum. It allocates memory for array represented by pointer w as well. The function adds new worker into the company. The function accepts the worker name and the hourly rate. The function displays a list of all workers name that are employed in the company. The function calculates and returns the total job cost that requires hours number of hours to complete. It assumes all the workers employed will be used. int addWorkers(string workerName, float a_hourly_pay) void listallworkers() float calculateJobCost(int hours) int main() { Company c1(5); c1.addWorkers(" Aunty annie", 5.e); c1.addWorkers(" Mcgyver", 8.0); c1.addWorkers(" Phua Chu Kang ", 10.6); c1.listallworkers(); float total = c1.calculateJobCost(2); // estimate salary cost for 2 hours job cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!