| Java's Object Orientation, I/O | CS 161 - Java |
This instance method should read information for a single Employee from an input source and create a new Employee object, returning the single Employee as the result.public Employee inputEmployeeRecord()
Employee records being read from an input file will consist of a name on one line, and an annual salary figure on the next line:
You might want to make use of the InputInterpreter class.
This method will open the file specified by the filename argument and use the inputEmployeeRecord method to read and create Employee objects. The resulting Employees should be stored in an instance array of Employees for later processing.public void inputFile(String filename)
Use the file of employee input data that is given on the next page.
For input, you may use either SavitchIn, InputInterpreter, or your own input/output and data interpretation capabilities.
If you use SavitchIn (which only reads from System.in (normally the keyboard), you can use input re-direction on both Windows and Unix:
though you'll have to figure out some way of handling how many employees are being entered or detecting the end of input. You may find it easier to use the InputInterpreter class. You must use the records provided. If you modify the input file in any way, please submit your modified input file too.java MyClass <employees.dat
This method should access each Employee object in the array that you populated in the inputFile() method. Use the Employee class' getSalary() method to access the employee's annual salary. Use the Employee class' getName() method to access the Employee's name. Calculate a biweekly salary amount (annual salary divided by 26 pay periods) and then report as output the employee's name and biweekly salary.public void processPayroll()
Have your Company class's main method make an instance of the Company class, then call inputFile with the name of the employee data file on that Company instance and finally call the Company instance's processPayroll() method.public static void main(String[] args)
Be sure to document your programs.
Hand in listings of your class source files, and a transcript of its execution.
|
jwd |