Problem Definition You are provided with a text file (employees.txt) containing a number of text lines. Each line contains a record of one employee. Each record has three attributes: Title: string,...


Problem Definition<br>You are provided with a text file (employees.txt) containing a number of text lines. Each line contains a record of one<br>employee. Each record has three attributes:<br>Title: string, Prof. (Professor) or Dr. (Doctor).<br>First and Last names: string.<br>Salary: float number.<br>The attributes are separated by the character (',). Figure 1.a, 1.b, and 1.c show a sample of employees.txt files.<br>Dr., Julia Scott, 141518<br>Dr., Julia Scott, 141518<br>Prof.,Joan Stewart, 111673<br>Mr.,Ali Al-shukaili,122311<br>Prof., Sana Al-Abri, 131673<br>Prof.,Joan Stewart<br>Dr., Fadi A1-Rasdhi, 153790<br>Ms., Salwa Al-Youssfi, 111675<br>Dr., Daniel Cooper, 153790<br>Dr., Lillian Brown, unknown<br>Dr. :Benjamin Russell:117642<br>Dr., Daniel Cooper, 153790<br>Dr., Lillian Brown, 67251<br>Dr., Benjamin Russell,117642<br>Prof., Patrick Bailey, 72305<br>Dr., Ralph Flores, 118457<br>Dr., Douglas Flores, 181793<br>Dr., Lillian Brown, 67251<br>Figure 1.b: A sample of the text file 'employees.txt

Extracted text: Problem Definition You are provided with a text file (employees.txt) containing a number of text lines. Each line contains a record of one employee. Each record has three attributes: Title: string, Prof. (Professor) or Dr. (Doctor). First and Last names: string. Salary: float number. The attributes are separated by the character (',). Figure 1.a, 1.b, and 1.c show a sample of employees.txt files. Dr., Julia Scott, 141518 Dr., Julia Scott, 141518 Prof.,Joan Stewart, 111673 Mr.,Ali Al-shukaili,122311 Prof., Sana Al-Abri, 131673 Prof.,Joan Stewart Dr., Fadi A1-Rasdhi, 153790 Ms., Salwa Al-Youssfi, 111675 Dr., Daniel Cooper, 153790 Dr., Lillian Brown, unknown Dr. :Benjamin Russell:117642 Dr., Daniel Cooper, 153790 Dr., Lillian Brown, 67251 Dr., Benjamin Russell,117642 Prof., Patrick Bailey, 72305 Dr., Ralph Flores, 118457 Dr., Douglas Flores, 181793 Dr., Lillian Brown, 67251 Figure 1.b: A sample of the text file 'employees.txt" Figure 1.a: A sample of the text file 'employees.txt' without errors Figure 1.e: A sample of the text file "employees.txt' including 3 invalid records including 2 records with incorrect titles You are requested to write a Python program that reads the contents of the text file, saves the titles, the names and the salaries of employees in three lists and computes the average salary per title as well as the average for all employees. Your program should display the employees per titles, the number of employees of each title, the average salary of each title, the average for all employees, as well as the number of records with invalid title, and the number of invalid record as shown in Figure 2.a, 2.b, and 2.c: ******** Salaries per category Salarles per category Salaries per category: ....... ........ **... ................ Nane Salary Salary Name Salary Prof. Joan Stevart 111673.00 Prof. Patrick telley 72s.00 Sana Al-Abri 131673.00 Dr. ***** The average salary ef 2 Prof. is: 91989.00 Julia Scott Daniel Cooper .. 141518.00 The average salary of 1 Prof. is: 131673.00 ***** . 153790.00 .. Julia Scett Daniel Ceeper Lllan Bron Benjanin Russell Ralph Fleres Douglas Fleres Dr. -... ... .. . .. 141518.0 15370.00 67251.00 15379.00 The average salary of 2 Dr. is: 147654.00 67251.00 117642.00 Fadi Al-Raschi Lillian Bron . .... ... 118457.00 181793.00 The number of records having incorrect title is e The number of invalid records is 3 The average salary of 2 Dr. is: 110520. se The nuber ef records having incorrect title is 2 The nuber ef invalid records is The average salary of 6 Dr, is: 130075.17 The nuber of records having incorrect title is . The nuber of invalid recerds is e Figure 2.b: The output of the program Figure 2.e: The output of the program Figure 2.a: The output of the program related to input file of figure L.a related to input file of figure 1.b related to input file of figure L.e Your program should handle the following error situations. File employees.txt not found, in which case an adequate error message should be displayed. b. Incorrect title (different from Prof.' or 'Dr.'), in which case increment the number of records having incorrect a. title. c. Invalid data (such as incorrect separator, less than 3 attributes, non-numerical salary, ...), in which case increment the number of invalid records.
Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here