Question: Question 2 (13 points): Work Hours A company keeps a record of the number of hours that an employee works for a particular month in

 Question 2 (13 points): Work Hours A company keeps a recordof the number of hours that an employee works for a particularmonth in a calendar year. Write a function workHours to read the

Question 2 (13 points): Work Hours A company keeps a record of the number of hours that an employee works for a particular month in a calendar year. Write a function workHours to read the txt file and store the name and work-hours in two separate arrays. The function returns the number of employees stored and prints out the average monthly work-hours for each employee. . O 0 Function specifications: The function name: workHours The function parameters (in this order): A file name of type string An array of type string to store names of employees A 2D int array with a row corresponding to each employee and 12 columns to store monthly work-hours of the employees The size of the array as an int (size meaning the total number of elements) The function returns an integer depending on the following conditions: It returns - 1 if the file cannot be opened. It returns the number of employees stored in the string array of employee names if the function can open and read the file The function also prints out the following For each employee, print a newline with the employee name and their average monthly work-hours rounded to 1 decimal place. o The name and work-hours number should be separated by a colon and space like "Karen: 44.3" . Sample file (hours.txt): John 60, 80, 50, 70, 85, 32, 94, 81, 45, 65, 91, 82 Alek 1, 25, 18, 22, 23, 16, 5, 33, 21, 27, 23, 102 Kate 55, 54, 52, 56, 58, 52, 51, 59, 58, 50, 54, 55 Sample run 1 (bold is user input) John: 69.6 Alek: 26.3 Kate: 54.5 return value: 3 Example structure for employee names array and sales 2D array for hours.txt. names [0] = John hours[][0] = 60 hours [0] [1] = 80 hours [O] [2] = 50 hours [O] [3] = 70 hours [O] [4] 85 hours [O] [5] = 32 hours [0] [6] = 94 hours [0] [7] 81 hours [O] [8] 45 hours [0] [9] 65 hours [0] [10] 91 hours [0] [11] 82 = Note: You should use the split() function to split each line of the file. The file should be named as workHours.cpp. Don't forget to head over to the CodeRunner on Canvas and paste only your function in the answer box! John 60, 80, 50, 70, 85, 32, 94, 81, 45, 65, 91, 82 Alek 1, 25, 18, 22, 23, 16, 5, 33, 21, 27, 23, 102 Kate 55, 54, 52, 56, 58, 52, 51, 59, 58, 50, 54, 55

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!