Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java application that will read in a binary file containing objects of HourlyEmployee type and create the weekly payroll. The payroll should be

Write a Java application that will read in a binary file containing objects of HourlyEmployee type and create the weekly payroll. The payroll should be written to a text file containing the hourly employee name and the pay for the week. The application should compute the weekly pay for each employee. The regular pay is the wageRate multiplied by hours worked less than or equal to 40 hours. For overtime pay, the wageRate should be multiplied by 1.5 for all hours worked over 40 hours. The file Payroll.java contains a skeleton of the program. Do the following:

1. Set up a ObjectInputStream object infile from the input file and a PrintWriter outFile to the output file inside the try clause (see the comments in the program). Note that youll have to create the PrintWriter from a FileWriter, but you can still do it in a single statement.

2. Inside the while loop add code to read the input file. Dont forget to cast each object to HourlyEmployee

. 3. Compute the weekly pay, then write the employee name and weekly pay to the output file.

4. After the loop close the PrintWriter.

5. Think about the exceptions that could be thrown by this program: An EOFException when the end of file has been reached A FileNotFoundException if the input file does not exist A ClassNotFoundException if the object class files does not exist An IOException if something else goes wrong with the input or output stream Add a catch for each of these situations, and in each case give as specific a message as you can. The program will terminate if any of these exceptions is thrown, but at least you can supply the user with useful information.

6. Test the program. Test data is in the file hourly.dat. Be sure to test each of the exceptions as well.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introductory Relational Database Design For Business With Microsoft Access

Authors: Jonathan Eckstein, Bonnie R. Schultz

1st Edition

1119329418, 978-1119329411

More Books

Students also viewed these Databases questions