Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In C++ Question 2 (13 points): Work Hours A company keeps a record of the number of hours that an employee works for a particular
In C++
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 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 o 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 o For each employee, print a newline with the employee name and their average monthly work-hours rounded to 1 decimal place. The name and work-hours number should be separated by a colon and space like "Karen: 44.3" o 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][0] = 60 hours[0][1] = 80 hours[0][2] = 50 hours[0][3] = 70 hours[0][4) - 85 hours ( OS) = 32 -- hours [0] [6] = 94 hours [0] [7] = 81 hours [0] [8] = 45 hours [0] [9] 65 hours [O] [10] = 91 hours [0] [11] = 82 Note: You should use the split() function to split each line of the fileStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started