COS10029 - Fundamentals of Programming SWIN BUR · NE . SWINBURNE UNIVERSITY OF TECHNOLOGY Fundamentals of Programming Week 9 - Lab exercises (Submit all tasks - Submit HD Task separately) Task 9.1 Things to do: 1. Read all employee details 2. Print all employee details 3. Print total salary of all employees 4. Print the details of an employee with the largest salary 5. Find the salary of a particular employee 6. Print the details of employee in reverse order Task 9.1 - Structure Chart main inFile, employee array, SIZE employee array, SIZE, name employee array, SIZE - employee array, SIZE employee array, SIZE index index total salary search_an_employee_salary read_all_employee print all employee employee_total_salary search largest salary_index inFile emplovee emplovee employee read employee print employee @Copyright: Swinburne University of Technology Week 9 Lab CRICOS: 0011D TOID: 3059 Page 1 of 4
COS10029 - Fundamentals of Programming SWIN BUR · NE . SWINBURNE UNIVERSITY OF TECHNOLOGY Write the C++ code to implement the program from the following description. Employee Details: This program will use an employee struct to store and work with employee data. Each employee has a name, an emp_id (integer), and a salary (float). Create a text file that contains the name emp_id and salary for 10 employees. Write a program that reads the details from the text file into an array of employee, and then prints the employees out to the Terminal. a. Declare the employee structure. b. Write a read_employee function that reads in the name, id, and salary from a text file and stores these in an employee variable which is then returned. This function has a parameter which is a reference to an input file stream. c. Write a read_all_employee function that receives three parameters. 1. reference to an input file stream 2. an array of employee values 3. size of the array. This function callsls read_employee function passing the file stream as argument and stores the result in each index of employee array. d. Write a print_employee function that accepts an employee parameter and prints the details of this employee to the terminal. Write the "name (emp_id): salary" followed by "Level A" if the salary is less than 4000, or "Level B" if the salary is greater than 5000. e. Write a print_all_employee function that receives an array of employee values in one parameter and size of the array in another parameter. This function calls print_employee function passing employee parameter in each index. f. Write an employee_total_salary function that accepts an array of employee values in one parameter and size of array in another parameter, and returns the sum of all of their salaries. g. Write a search_largest_salary_index function that accepts an array of employee values in one parameter and the size of the array in the second parameter. The function will search the array for the largest salary and return its index (position in the array). e. Write a search_an_employee_salary function that accepts an array of employee values in one parameter, the size