2.2 Task 2 [3 marks] In the staff.h file, add elements in the structure "StaffInfo" to store the following information:
Posted: Tue Jul 12, 2022 8:05 am
/*---------------------------------------------------------------------------------------* * Structure: StaffInfo * -------------------- * Structure to store staff information * * IMPORTANT! Only edit between the marked lines. *---------------------------------------------------------------------------------------*/struct StaffInfo { int id; //<---------------------- START editing here-------------------->//
//<----------------------- STOP editing here-------------------->//};
/*---------------------------------------------------------------------------------------* * Function: open_file * -------------------- * Opens a file named with your matric number. Do not closethe created file * * Arguments: None * * Returns: File pointer to created file (do not edit) * Returns NULL if filecreation fails * * IMPORTANT! Only edit between the marked lines. DO NOT CLOSETHE CREATED FILE. *---------------------------------------------------------------------------------------*/FILE *open_file(void);
/*---------------------------------------------------------------------------------------* * Function: enter_staff_info * -------------------- * Enters staff info in the structure. The main function willcall this function every * time there is a new staff info to be entered. You DO NOThave to iterate for multiple * staff data entry. * * Arguments: struct StaffInfo pointer - points to staff infoin StaffInfo structure * * Returns: None * * IMPORTANT! Only edit between the marked lines. *---------------------------------------------------------------------------------------*/void enter_staff_info(struct StaffInfo *staff_info);
/*---------------------------------------------------------------------------------------* * Function: print_staff_info * -------------------- * Prints newly entered staff info from the StaffInfostructure on the terminal. This * function will be called by the main function for everystaff info entered. You DO NOT * have to iterate to print multiple staff info. * * Arguments: struct StaffInfo - staff info structure * * Returns: None * * IMPORTANT! Only edit between the marked lines. *---------------------------------------------------------------------------------------*/void print_staff_info(struct StaffInfo staff_info);
/*---------------------------------------------------------------------------------------* * Function: store_staff_info * -------------------- * Stores newly entered staff info into file pointed by fp.The main function will call * this function for every staff info entered. You DO NOT haveto iterate for every staff * info. * * Arguments: FILE *fp - pointer to file where the informationwill be stored * struct StaffInfo -structure containing staff info * * Returns: None * * IMPORTANT! Only edit between the marked lines. *---------------------------------------------------------------------------------------*/void store_staff_info(FILE *fp, struct StaffInfo staff_info);
/*---------------------------------------------------------------------------------------* * Function: load_staff_file * -------------------- * Loads staff information file. This function should openexisting staff info file and * inserts it into the struct StaffInfo loaded_staff_data[10]array as declared at the * top of this (staff.c) file. * * If you choose to skip implementation of this function, youcan proceed with next task * by uncommenting lines 15 - 26 in staff.c (delete line 15and 26). You may need to change * your struct StaffInfo elements to accommodate the defaultdata. * * Arguments: None * * Returns: File pointer to created file (do not edit) * Returns NULL if filecreation fails * * IMPORTANT! Only edit between the marked lines. *---------------------------------------------------------------------------------------*/FILE *load_staff_file(void);
/*---------------------------------------------------------------------------------------* * Function: calculate_salary_difference * -------------------- * Calculates salary difference of staff compared to staffsalary based on experience. The * expected salary can be calculated as follows: * Expected salary = basic *(1.1)^(years of experience) * This function stores all the information of the staff intothe file created in * open_file(). * * Arguments: FILE *fp - file pointer to the created file inopen_file * int new_staff_no -total number of new staff info added * struct StaffInfo*staff_info - pointer to an array of StaffInfo structure. * You have to iterate through the array elements toaccess each staf * info. * * Returns: None * * IMPORTANT! Only edit between the marked lines. *---------------------------------------------------------------------------------------*/void calculate_salary_difference (FILE *fp, int new_staff_no,struct StaffInfo *staff_info);
2.2 Task 2 [3 marks] In the staff.h file, add elements in the structure "StaffInfo" to store the following information: a. b. c. d. Job title Full Name City of birth Year of joining company e. Monthly Salary *ID has been created as an element of the "StaffInfo" structure.