Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

REALLY NEED HELP WITH THIS ASSIGNMENT!! Objectives: The focus of this assignment

ID: 3574693 • Letter: R

Question

REALLY NEED HELP WITH THIS ASSIGNMENT!!

Objectives: The focus of this assignment is the use of both character sequential files and Object Serialized files

Program Description:

The EmployeeManager will now have the ability to save the current Employees to a file, as well as load Employees from a previous session. Additionally, it will be capable of processing files that will apply multiple Employee updates.

A total of fourteen classes are required.

Queue – (From previous assignment)

ListNode – (From previous assignment)

LikedList – (From previous assignment)

EmptyListException – (From previous assignment)

ArrayList - (From previous assignment)

InvalidEmployeeNumberException - (From previous assignment)

InvalidSizeException - (From previous assignment)

MaximumCapacityException - (From previous assignment)

Employee - (Altered from previous assignment)

HourlyEmployee - (From previous assignment)

SalaryEmployee - (From previous assignment)

CommissionEmployee - (From previous assignment)

EmployeeManager - (Altered from previous assignment)

EmployeeDriver - (Altered from previous assignment)

Changes to Employee

The Employee class must now implement the Serializable interface in order to be used with Object Serialization

Employee {abstract} implements Comparable<Employee>, Serializable

- String firstName

- String lastName

- char middleInitial

- boolean fulltime

-   char gender

-   int employeeNum

<<constructor>> Employee (fn : String, ln : String, m : char, g : char, empNum : int, ft : boolean ) throws InvalidEmployeeNumberException

+ getEmployeeNumber() : int

+ setEmployeeNumber(empNum : int)

+ getFirstName() : String

+ getLastName() : String

+ setFirstName(fn: String)

+ setLastName(ln : String)

+ setMiddleI(m : char)

+ setGender(g : char)

+ equals(e2 : Object) : Boolean

+ toString() : String

+ calculateWeeklyPay() : double {abstract}

+ annualRaise() {abstract}

+ holidayBonus() : double {abstract}

+ resetWeek() {abstract}

+ compareTo(Employee e)

Changes to EmployeeManager

The EmployeeManager will now be able to save and load the Employees from session to session using Serialized files. It will also be able to process text files to quickly update multiple Employees.

EmployeeManager

- employees : ArrayList<Employee>

- employeeMax : final int = 10

- hourlyList : LinkedList<Employee>

- salaryList : LinkedList<Employee>

- commissionList : LinkedList<Employee>

- vacationRequests : Queue<Employee>

<<constructor>> EmployeeManager()

+ addEmployee( type : int, fn : String, ln : String, m : char, g : char, en : int, ft : boolean, amount : double) throws InvalidEmployeeNumberException

+ removeEmployee( index : int)

+ listAll()

+ listHourly()

+ listSalary()

+ listCommision()

+ resetWeek()

+ calculatePayout() : double

+ getIndex( empNum : int ) : int

+ annualRaises()

+ holidayBonuses() : double

+ increaseHours( index : int, amount : double)

+ increaseSales( index : int, amount : double)

+ findAllBySubstring(find : String) : Employee[]

- RabinKarp(name : String, find : String) : int

- stringHash(s : String) : int

- charNumericValue(c : char) : int

- RabinKarpHashes(s : String, hashes : int[], pos : int, length : int) : int

- linearSearchRecursive(nameHashes : int[], findHash : int, pos : int) : int

+ sort()

+ addRequest(empNum : int) : boolean

+ viewNextRequest() : Employee

+ grantNextRequest() : Employee

+ outputRequests()

+ loadEmployees(employeeFile : String, requestFile : String) boolean

+saveEmployees(employeeFile : String, requestFile : String) boolean

+processUpdates(fileName : String) boolean

public boolean loadEmployees(String employeeFile, String requestFile)

Given the name of a serialized file (employeeFile), this method attempts to read in Employees from a previous session. This method will return true if the load of Employees was successful and false if it was not successful (file doesn’t exist, ClassNotFoundException, or other IOException). Before reading in the Employees it will clear all of the lists to ensure it is loading into an empty set of Employees. This includes the ArrayList, the LinkedLists, and the Queue. If a MaximumCapacityException is encountered while adding Employees output “Maximum Capacity Reached”, and return true. The method will also open the text file (requestFile) to rebuild the vacation request Queue.

public boolean saveEmployees(String employeeFile, String requestFile)

This method will store all of the Employees as Serialized objects in the employeeFile and the Employee numbers in the correct order of those in the vacation Queue as plain text, placing a new line after every number.

public boolean processUpdates(String fileName)

Given the name of a text file, this method will process the update requests within the file. A valid update request is in the form:

EMPLOYEE_NUMBER AMOUNT

Where the two values are separated by a space. Employee numbers are ints, amount can be a double. It will skip updates with a negative amount. If an improperly formatted update request is reached it will skip that update and proceed to the next update.

To correctly apply an update you must call upon either increaseHours or increaseSales method of the EmployeeManager, depending on the type of employee that has the given Employee number. Employee numbers that do not exist or Employee numbers of SalaryEmployees are skipped.

Changes to EmployeeDriver

Before the Main Menu loop call upon the EmployeeManager’s loadEmployees with the file name of “employees.ser” and “requests.dat”. If the load is successful output “Employees Loaded”, if it was not successful output “Employees Not Loaded”.

Upon exit call upon the EmployeeManager’s saveEmployees. After the “Thank you for using the Employee Manager!” message, if the save was successful output “Employees stored”, if unsuccessful output “Employes not stored”.

Add a new menu option, “Employee Updates” after “Grant Request”. Employee Updates will now be option 13, moving Exit to option 14. This option will ask the user for the name of an update file, read it in and call upon the EmployeeManager’s processUpdates method. If this is done successfully output “Updates processed successfully”, otherwise output “Updates not processed”.

The first time you execute the loading of files will not succeed since there is no “employees.ser” file. After that it should always succeed.

If you need to retest your program from scratch, that is from the first run, you can remove the .ser file that is created with the rm command.

rm employees.ser

rm requests.dat

Other Notes:

Import classes to files as necessary

When loading Employees be sure to add them to their own lists as well!

Name the file for the Serialized Employees “employees.ser” and the vacation request Employee numbers “requests.dat”

Example (user input underlined, bolded comments not in actual output)

To begin with there is no “employees.ser” file. The contents for the update files used for this example are at the bottom

Employees Not Loaded No files exists

Main Menu

No Employees.

1. Employee Submenu

2. Add Employee

3. Remove Employee

4. Calculate Weekly Payout

5. Calculate Bonus

6. Annual Raises

7. Reset Week

8. Find Employee

9. Sort

10. View Vacation Requests

11. Add Vacation Request

12. Grant Vacation Request

13. Employee Updates

14. Quit

Enter Choice:

After adding some Employees and exiting

Main Menu

12348

Doe, John A.

Gender: M

Status: Full Time

Wage: 14.75

Hours Worked: 0.00

12345

Cavanaugh, Patrick B.

Gender: M

Status: Full Time

Wage: 10.00

Hours Worked: 0.00

12346

Bohning, Edith C.

Gender: F

Status: Part Time

Salary: 50000.00

12347

Pohnal, Rickie A.

Gender: F

Status: Full Time

Rate: 2.50

Sales: 0.00

1. Employee Submenu

2. Add Employee

3. Remove Employee

4. Calculate Weekly Payout

5. Calculate Bonus

6. Annual Raises

7. Reset Week

8. Find Employee

9. Sort

10. View Vacation Requests

11. Add Vacation Request

12. Grant Vacation Request

13. Employee Updates

14. Quit

Enter Choice: 14

Thank you for using the Employee Manager!

Employees stored Employees successfully stored

Starting the driver again

Employees Loaded Employees from previous session loaded successfully

Main Menu

12348

Doe, John A.

Gender: M

Status: Full Time

Wage: 14.75

Hours Worked: 0.00

12345

Cavanaugh, Patrick B.

Gender: M

Status: Full Time

Wage: 10.00

Hours Worked: 0.00

12346

Bohning, Edith C.

Gender: F

Status: Part Time

Salary: 50000.00

12347

Pohnal, Rickie A.

Gender: F

Status: Full Time

Rate: 2.50

Sales: 0.00

1. Employee Submenu

2. Add Employee

3. Remove Employee

4. Calculate Weekly Payout

5. Calculate Bonus

6. Annual Raises

7. Reset Week

8. Find Employee

9. Sort

10. View Vacation Requests

11. Add Vacation Request

12. Grant Vacation Request

13. Employee Updates

14. Quit

Enter Choice: 13 Process update file

Enter name of update file: update1

Updates processed successfully

Main Menu

12348

Doe, John A.

Gender: M

Status: Full Time

Wage: 14.75

Hours Worked: 35.75

12345

Cavanaugh, Patrick B.

Gender: M

Status: Full Time

Wage: 10.00

Hours Worked: 20.56

12346

Bohning, Edith C.

Gender: F

Status: Part Time

Salary: 50000.00

12347

Pohnal, Rickie A.

Gender: F

Status: Full Time

Rate: 2.50

Sales: 10000.54

1. Employee Submenu

2. Add Employee

3. Remove Employee

4. Calculate Weekly Payout

5. Calculate Bonus

6. Annual Raises

7. Reset Week

8. Find Employee

9. Sort

10. View Vacation Requests

11. Add Vacation Request

12. Grant Vacation Request

13. Employee Updates

14. Quit

Enter Choice: 13 Process another

Enter name of update file: update2

Updates processed successfully

Main Menu

12348                                       Note the update with a negative value was not processed, and the update

Doe, John A.                             after the incorrectly formatted update still occurred

Gender: M

Status: Full Time

Wage: 14.75

Hours Worked: 35.75

12345

Cavanaugh, Patrick B.

Gender: M

Status: Full Time

Wage: 10.00

Hours Worked: 20.56

12346

Bohning, Edith C.

Gender: F

Status: Part Time

Salary: 50000.00

12347

Pohnal, Rickie A.

Gender: F

Status: Full Time

Rate: 2.50

Sales: 10500.54

1. Employee Submenu

2. Add Employee

3. Remove Employee

4. Calculate Weekly Payout

5. Calculate Bonus

6. Annual Raises

7. Reset Week

8. Find Employee

9. Sort

10. View Vacation Requests

11. Add Vacation Request

12. Grant Vacation Request

13. Employee Updates

14. Quit

Enter Choice: 14 Exit

Thank you for using the Employee Manager!

Employees stored

Restarting one more time to show updates are also stored

Employees Loaded

Main Menu

12348

Doe, John A.

Gender: M

Status: Full Time

Wage: 14.75

Hours Worked: 35.75

12345

Cavanaugh, Patrick B.

Gender: M

Status: Full Time

Wage: 10.00

Hours Worked: 20.56

12346

Bohning, Edith C.

Gender: F

Status: Part Time

Salary: 50000.00

12347

Pohnal, Rickie A.

Gender: F

Status: Full Time

Rate: 2.50

Sales: 10500.54

1. Employee Submenu

2. Add Employee

3. Remove Employee

4. Calculate Weekly Payout

5. Calculate Bonus

6. Annual Raises

7. Reset Week

8. Find Employee

9. Sort

10. View Vacation Requests

11. Add Vacation Request

12. Grant Vacation Request

13. Employee Updates

14. Quit

Enter Choice: 14

Thank you for using the Employee Manager!

Employees stored

Contents of update files used for this example:

update1

12348 35.75

12345 20.56

12346 90.12

12347 10000.54

update2

12345 -15.25

30.5 12348

12347 500

These are two sample updates. They do not encapsulate all possibilities and cases to check for. Be sure to create and test your own update files.

Employee {abstract} implements Comparable<Employee>, Serializable

- String firstName

- String lastName

- char middleInitial

- boolean fulltime

-   char gender

-   int employeeNum

<<constructor>> Employee (fn : String, ln : String, m : char, g : char, empNum : int, ft : boolean ) throws InvalidEmployeeNumberException

+ getEmployeeNumber() : int

+ setEmployeeNumber(empNum : int)

+ getFirstName() : String

+ getLastName() : String

+ setFirstName(fn: String)

+ setLastName(ln : String)

+ setMiddleI(m : char)

+ setGender(g : char)

+ equals(e2 : Object) : Boolean

+ toString() : String

+ calculateWeeklyPay() : double {abstract}

+ annualRaise() {abstract}

+ holidayBonus() : double {abstract}

+ resetWeek() {abstract}

+ compareTo(Employee e)

Explanation / Answer

//EmployeeManager.java

import java.util.Scanner;
import java.io.FileNotFoundException;
import java.util.NoSuchElementException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.IOException;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Formatter;
import java.util.FormatterClosedException;
public class EmployeeManager
{
private ArrayList<Employee> employees;
private final int employeeMax = 10;
private LinkedList<Employee> hourlyList;
private LinkedList<Employee> salaryList;
private LinkedList<Employee> commissionList;
private Queue<Employee> vacationRequests;
public EmployeeManager()
{ try { employees = new ArrayList<Employee>(3); }

catch (InvalidSizeException E)
{ try { employees = new ArrayList<Employee>(employeeMax);
}
catch (InvalidSizeException e) { } }
hourlyList = new LinkedList<Employee>();
salaryList = new LinkedList<Employee>();
commissionList = new LinkedList<Employee>();
vacationRequests = new Queue<Employee>(); }
public String addEmployee(int type, String fn, String ln, char m, char g, int en, boolean ft, double amount) throws InvalidEmployeeNumberException, MaximumCapacityException
{
   String s = "";
   for (int x = 0; x < employees.lengthIs(); x++)
   {         if (employees.getItem(x).getEmployeeNumber() == en)        
   {             System.out.print("error 12");
           s = "error";
               return s;         }     }
if (type == 1)
{ HourlyEmployee E = new HourlyEmployee (fn,ln,m,g,en,ft,amount);
employees.addItem(E);
hourlyList.insertAtBack(E);
s = "hourly";
}
if (type == 2)
{ SalaryEmployee E = new SalaryEmployee (fn,ln,m,g,en,ft,amount);
employees.addItem(E);
salaryList.insertAtBack(E);
s = "salary"; }
if (type == 3)
{ CommissionEmployee E = new CommissionEmployee (fn,ln,m,g,en,ft,amount);
employees.addItem(E);
commissionList.insertAtBack(E);
s = "commission";
} return s; }

public void removeEmployee(int index)
{     Employee temp = employees.getItem(index);
           if (employees.getItem(index) instanceof HourlyEmployee)
           {                 employees.removeItem(index);
                               hourlyList.findAndRemove(temp);
           }
           else if (employees.getItem(index) instanceof SalaryEmployee)
           {                 employees.removeItem(index);
                   salaryList.findAndRemove(temp);
              
           }
           else if (employees.getItem(index) instanceof CommissionEmployee)
           {                 employees.removeItem(index);
                               commissionList.findAndRemove(temp);
           } }

public String listAll()
{     String x = "";
if(employees.isEmpty() == true)
{     x = "No Employees"; }
for(int y = 0; y < employees.lengthIs(); y++)
{         x += employees.getItem(y).toString() + " "; }
return x;
}
public String listHourly()
{     String a = "";
   if (hourlyList.isEmpty() == true)
   {         a = "No Hourly Employees";     }
for (int x = 0; x < hourlyList.lengthIs(); x++)
{         a += hourlyList.getItem(x).toString() + " "; }
return a;
}
public String listSalary()
{     String b = "";
   if(salaryList.isEmpty() == true)
   {         b = "No Salary Employees";     }
   else
   {         for (int x = 0; x < salaryList.lengthIs(); x++)
   {           b += salaryList.getItem(x).toString() + " ";   }
   } return b; }
public String listCommission() {
   String c = "";
   if(commissionList.isEmpty() == true)     {         c = "No Commission Employees";     }
for (int x = 0; x < commissionList.lengthIs(); x++)
{         c += commissionList.getItem(x).toString() + " "; }
return c; }
public void resetWeek()
{ for (int a = 0; a < employees.lengthIs(); a++) { employees.getItem(a).resetWeek(); }
}
public double calculatePayout()
{ double payout = 0;
for (int a = 0; a < employees.lengthIs(); a++)
{ payout += employees.getItem(a).calculateWeeklyPay();
           System.out.printf(" %f ", payout);
} return payout;
}
public int getIndex(int empNum)
{ for (int a = 0; a < employees.lengthIs(); a++)
if (empNum == employees.getItem(a).getEmployeeNumber())
return a;
return -1;
}
public void annualRaises()
{ for (int a = 0; a < employees.lengthIs(); a++) { employees.getItem(a).annualRaise();
} }
public double holidayBonuses()
{
double payout = 0;

for (int a = 0; a < employees.lengthIs(); a++)
{
payout += employees.getItem(a).holidayBonus();
//System.out.print (employees.getItem(a).toString());

double b = employees.getItem(a).holidayBonus();

System.out.printf ("Bonus ammount: %.2f", b);
System.out.print (" ");
}

return payout;
}
public boolean increaseHours(int index, double amount)
{
if (employees.getItem(index) instanceof HourlyEmployee)
{

((HourlyEmployee)employees.getItem(index)).increaseHours(amount);
}
else    return false; return true;
}
public boolean increaseSales(int index, double amount)
{
if (employees.getItem(index) instanceof CommissionEmployee)
{ ((CommissionEmployee)employees.getItem(index)).increaseSales(amount); }
else
{     return false; }
return true;
}
public ArrayList<Employee> findAllBySubstring(String find)
{ ArrayList<Employee> ken = new ArrayList<Employee>();
for (int a = 0; a < employees.lengthIs(); a++)
{ if((RabinKarp((employees.getItem(a).getFirstName() + employees.getItem(a).getLastName()), find)) != -1)
{ try {
ken.addItem(employees.getItem(a));
System.out.print(employees.getItem(a).toString() + " ");
}
catch (MaximumCapacityException e)
{ System.out.print("too large"); } } }
return ken; }
private int RabinKarp(String name, String find)
{
if (find.length() > name.length())
return -1;
int findHash = stringHash(find);
int [] nameHash = new int [name.length() - find.length() + 1];
String sub = name.substring(0, find.length());
nameHash[0] = stringHash(sub);
RabinKarpHashes(name, nameHash, name.length() - find.length(), find.length());
int x = linearSearchRecursive(nameHash, findHash, name.length() - find.length());
return x;
}
private int stringHash (String s)
{
int hash = 0;
for(int i = 0; i < s.length(); i++)
{ hash += charNumericValue(s.charAt(i)) * Math.pow(26, s.length() - i - 1); }
return hash;
}
private int charNumericValue(char c) throws InvalidCharacterException
{ switch (c) {
case 'a': case 'A': return 0;
case 'b': case 'B': return 1;
case 'c': case 'C': return 2;
case 'd': case 'D': return 3;
case 'e': case 'E': return 4;
case 'f': case 'F': return 5;
case 'g': case 'G': return 6;
case 'h': case 'H': return 7;
case 'i': case 'I': return 8;
case 'j': case 'J': return 9;
case 'k': case 'K': return 10;
case 'l': case 'L': return 11;
case 'm': case 'M': return 12;
case 'n': case 'N': return 13;
case 'o': case 'O': return 14;
case 'p': case 'P': return 15;
case 'q': case 'Q': return 16;
case 'r': case 'R': return 17;
case 's': case 'S': return 18;
case 't': case 'T': return 19;
case 'u': case 'U': return 20;
case 'v': case 'V': return 21;
case 'w': case 'W': return 22;
case 'x': case 'X': return 23;
case 'y': case 'Y': return 24;
case 'z': case 'Z': return 25;
}
throw new InvalidCharacterException(c); }
private int RabinKarpHashes (String s, int[] hashes, int pos, int length)
{
if (pos == 0)
{
hashes[pos] = stringHash(s.substring(pos, pos + length));
}
if (pos > 0)
{
hashes[pos] = 26 * (RabinKarpHashes(s,hashes,pos-1, length) - charNumericValue(s.charAt(pos-1)) * (int)Math.pow(26,length-1)) + charNumericValue(s.charAt(pos+length-1));
}

return hashes[pos];


}
private int linearSearchRecursive(int[] data, int key, int pos)
{
if (pos < 0)
{ return -1; }

if (key == data[pos])
{ return pos; }

return linearSearchRecursive(data, key, pos-1);

}
public void sort()
{
   hourlyList.sort();
   salaryList.sort();
   commissionList.sort();
   employees.sort();
}
public boolean addRequest(int empNum)
{
if (empNum > 10000 && empNum < 99999)
{
vacationRequests.enqueue(employees.getItem(getIndex(empNum)));
System.out.println(empNum);
return true;
}

else
return false;
}
public Employee viewNextRequest()
{     return vacationRequests.peek(); }
public Employee grantNextRequest()
{ if (vacationRequests != null)
{ return vacationRequests.dequeue(); }
else
return null; }
public String outputRequests()
{ if (vacationRequests != null)
return vacationRequests.toString();
else
return "No vacation requests"; }
@SuppressWarnings("resource")
   public boolean loadEmployees(String employeeFile, String requestFile)
{
FileInputStream file, file1;
ObjectInputStream inout = null ;
Scanner in;
Queue<Employee> q = null;
int emp = 0;
employees.clear();
hourlyList.clear();
salaryList.clear();
commissionList.clear();
vacationRequests.clear();
try
{
inout = new ObjectInputStream(new FileInputStream(employeeFile));
while(true)
{
   Employee ee = (Employee)(inout.readObject());
   //System.out.println(ee);
employees.addItem(ee);
if (ee instanceof HourlyEmployee)
{     hourlyList.insertAtBack(ee); }
if (ee instanceof SalaryEmployee)
{     salaryList.insertAtBack(ee); }
if (ee instanceof CommissionEmployee)
{     commissionList.insertAtBack(ee); }
}
}
catch (FileNotFoundException fnfe)
{ System.out.println("Error"); }
catch (EOFException eofee)
{
   try
   {         inout.close();     }
   catch (IOException ioe)
{
System.err.println("etr12344");
System.exit(0);
}
}
catch (IOException ioe)
{ System.err.println("etr"); }
catch (MaximumCapacityException mce)
{
System.out.print("Maximum Capacity Reached");
return true;
}
catch (ClassNotFoundException cnfe)
{ System.out.print("err"); }
if (inout == null)
{ return false; }
  
try
{           inout.close();       }
catch (IOException e)
{
           System.exit(0);
           e.printStackTrace();
       }

//
try
{ file = new FileInputStream(employeeFile); }
catch (IOException a)
{ System.err.println("err"); return false; }
try
{ if (file != null) { file.close(); }
}
catch (IOException IOE)
{
System.err.println("error closing file");
System.exit(1);
}
try
{ in = new Scanner(new File(requestFile)); }
catch (FileNotFoundException fnfe)
{
System.err.println("err");
return false;
}

while (true)
{
try
{
emp = in.nextInt();
vacationRequests.enqueue(employees.getItem(getIndex(emp)));
}
catch (NoSuchElementException nsee)
{ break; }
}
  
try
{     in.close(); }
catch (IllegalStateException iseee)
{
   System.err.println("Scanner closed error.");
System.exit(1);
}

//
try { file1 = new FileInputStream(requestFile); }
catch (IOException ioe)
{
System.out.print("err");
return false;
}

try
{
if (file1 != null)
{ file1.close(); }
}
catch (IOException ioe)
{
System.out.print("err");
System.exit(1);
}
  
  
return true;
}
@SuppressWarnings("resource")
   public boolean saveEmployees(String employeeFile, String requestFile)
{
ObjectOutputStream output;
Formatter put = null;
try
{ output = new ObjectOutputStream(new FileOutputStream(employeeFile)); }
catch (IOException a)
{
System.out.println("error66");
System.exit(1);
return false;
}

for (int x = 0; x < employees.lengthIs(); x++)
{
try
{ output.writeObject(employees.getItem(x)); }
catch (IOException a)
{
System.out.print("Error77");
return false;
}
}
  
try
{           output.close();       }
catch (IOException e)
{           System.exit(0);           e.printStackTrace();       }
try
{
put = new Formatter(requestFile);
  
while(vacationRequests.isEmpty() == false)
{         put.format("%d ", vacationRequests.dequeue().getEmployeeNumber()); }
}
catch (FormatterClosedException fce)
{
System.out.println("error99");
return false;
}
catch (FileNotFoundException fnfee)
{ System.out.print("err10"); }
if (put != null)
{ put.close(); }
return true;
}
public boolean processUpdates(String fileName)
{
int emp = 0;
double requesT = 0.0;
Scanner input;
try
{ input = new Scanner(new File(fileName)); }
catch (FileNotFoundException fnfe)
{
System.out.print("Error, file not found");
System.exit(1);
return false;
}

while (true)
{ try
{ emp = input.nextInt(); requesT = input.nextDouble(); }
catch(NoSuchElementException nsee)
{ break; }
catch(IllegalStateException ISE)
{ System.err.println("Scanner closed error."); System.exit(1); }
int temp;
temp = getIndex(emp);
if (employees.getItem(temp) instanceof HourlyEmployee)
{ increaseHours(emp, requesT); }
if (employees.getItem(temp) instanceof SalaryEmployee)
{ System.out.print("Cannot process update."); }
if (employees.getItem(temp) instanceof CommissionEmployee)
{ increaseSales(emp,requesT); }
if (temp == -1)
{ System.out.printf("Cannot process update %d is an invalid employee number.", emp); }
}
  
try
{     if (input != null)     {         input.close();     } }
catch(IllegalStateException ISE)
{ System.err.println("Scanner closed error.");
System.exit(1); }
return true;
}
}