Question: Question 2: Storing Employee Records in a Heap (java program) In this question you will use heap data structures to store employee records. The premise

Question 2: Storing Employee Records in a Heap (java program) In this question you will use heap data structures to store employee records. The premise for this question is that you have been contracted to do some data processing by CompanyA, who has recently acquired CompanyB and is merging operations. CompanyA wants to streamline operations and will lay off 10 employees. They are undecided about whether to lay off the 5 most junior employees from each company, or the 10 most junior employees overall (ie. the 10 employees who began working most recently). CompanyA needs you to merge the employee information from the two companies, and produce lists of the potential layoffs. You have been provided with two files, A5CompanyA.txt and A5CompanyB.txt, containing the lists of employees. Each file contains one employee per line, in the format , with spaces between fields. 2 You MUST use a heap data structure to store the employees, and the heap MUST be implemented using an array. Your program will perform the following tasks: Create a heap data structure, and fill it with the employee records contained in the file A5CompanyA.txt. Create a second heap data structure, and fill it with the employee records contained in the file A5CompanyB.txt. Create a third heap data structure, and fill it so that it contains all employee records, representing the employee information after the merger of CompanyA with CompanyB. This task should be accomplished by a method (constructor) of the heap class. The constructor should accept two heaps as parameters, and fill the new heap with data from the given heaps. You will have to devise an algorithm that merges two heaps into one. In the method header comments, in one paragraph, describe the algorithm you use to merge two heaps into one heap. Be careful that you do not destroy the two small heaps in the process. All three heaps should exist after the merger. Use appropriate helper methods. Print the result of the first layoff possibility. List the 5 most junior employees from each company, before the merger. Also print the sum of the salaries for the 10 employees who would be laid off. Hint: You will not need the CompanyA or CompanyB heaps again, and can destroy it as you print the list. Print the result of the second layoff possibility. List the 10 most junior employees after the merger, and print the sum of their salaries. Hint: You will not need the merged heap again, and can destroy it as you print the list. Additional Notes You must decide whether to use a descending-order or ascending-order heap, and which data will be used to order the employees. In the header comment for the heap class, include a statement on how you have chosen to order your heap, and why you chose that ordering. Your program must be able to handle invalid input without crashing. If invalid data is encountered while loading data from a file, do not add that employee to the heap, print a message (containing the data) that the employee was not added, and continue with the next employee. Any omitted employees will not be considered in the final lists. You may assume that the format of employee records is always valid, and no expected fields are missing. That is, you can assume that you will have two strings (name), followed by three integers (year, month, day), followed by a double (salary in dollars), and that all will be separated by a space. Your program should follow good programming practices. Each element in the heap array should each contain one employee record. Any data members should be private, and get & set methods should be used to safely access and return data. The constructor for the employee class should accept all data fields for the employee, and return a valid instance of the employee class.

A5CompanyB

Teodor Mollown 2015 5 20 50830.72 Roshan Olmo 1989 4 6 103015.89 Richard Valentinov 2012 8 2 87839.20 Yulia Kozlov 1992 7 7 85478.25 Vivian Steele 3002 5 16 65345.99 Sabina Bosch 1976 2 24 51597.81 Paula Salmon 2002 1 4 56707.04 Khushi Mihajlovic 1994 10 3 147606.32 Rue Zuniga 2031 8 28 40469.62 Valter Herrero 1979 9 24 71635.15 Carmina Kaluza 2004 1 15 91726.42 Elior Beitel 2008 1 17 55192.09 Nik Kalb 2010 3 19 86876.08 Aage Austin 1981 2 25 68067.42 Ohiyesa Broz 2016 7 28 142078.62 Gort Kunkel 2005 12 30 84891.68 Glenys Carstensen 1999 12 27 39357.04

A5CompanyA

Fred Horton 2014 10 16 40469.22 Bertrand Cleary 1996 12 11 60505.30 Taegan Oquendo 1988 9 12 51530.37 Chetana Banes 1974 9 4 89609.01 Gopala Kuchler 2012 4 11 38637.29 Margit Aritza 1995 6 15 196406.85 Eireann Bai 1996 15 12 64832.32 Mariya Willemse 1993 5 31 93357.68 Nirav Lamberti 2014 8 21 -83573.72 Vilhelms Trujillo 1999 6 1 57515.93 Radhika Rutherfurd 1996 8 15 41732.92 Antonina McAfee 2018 1 17 79895.95 Wynona Maynard 2005 7 25 70860.83 Sabellius Rendon 1982 2 24 32969.37 Varuna Seres 2015 10 28 68388.22 Saoul Rijnders 1983 3 11 38431.29 Mitre Fulop 2014 1 15 98088.62 Adelaide Hailey 2008 6 5 44390.72 Natanael Severijns 2015 10 2 73393.72 Evgenia Strickland 1987 11 23 87312.37 Lucilla Pan 2006 8 3 120076.36 Lyla Cruz 1998 1 12 75800.36 Gwynfor Potter 2000 11 14 81624.94 Ian Yanev 2009 9 15 94860.28 Arijana Treloar 1984 5 17 105107.29 Dan Slovak 1998 1 29 73647.02 Magdalena Crespo 1995 2 30 99239.31 Doretta Newell 1988 5 6 67686.09 Ninoslav Nicastro 2011 6 10 42280.58 Koloman Rendon 1991 10 22 37103.78 Irvin Wang 2009 12 10 164914.44

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!