Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose that a university stores its employee records as a file In.dat in random-access format . The Records in the file have the fields: employeeId,

Suppose that a university stores its employee records as a file In.dat in random-access format. The Records in the file have the fields: employeeId, telephone, name, years_of_Work. For example, the file contains the record:

3046 416-555-6666 Burgess 15

Write the Java applet UpdateEmp which reads 10,000 records from the external file In.dat and creates an array of Record objects. Assume that the employeeId values are: 1,2, Also assume that some of the records in the external file are blanc and the array of Record objects should not contain them.

The class Record API is given below:

public Record () // constructor

public Record(int empId, String phone, String name, int years) // constructor

public void read( RandomAccessFile file ) throws IOException

public void write( RandomAccessFile file ) throws IOException

public int getEmpId()

public String getName()

public String getTelephone()

public int getYears()

public void setEmpId(int e)

public void setName(String n)

public void setTelephone(String t)

public void setYears(int y)

public String toString()

public int size()

Important Note: You do not have to write class Record. Also, as you do not have this class, you will not be able to compile this Java program.

After the creation of the array of Record objects the applet presents the following user interface:

1) at the top the label "Update Program" centered

2) below the table with 4 labels, 4 textfields and 3 buttons:

Employee Identification

10

Telephone Number

416-555-6666

Employee Name

Burgess

Years of Work

15

Get Record

Update

Display All Records

Note that the data shown in the right-hand textfields corresponds to the data shown in the sample of a Record.

3) below this table there is a text area.

Inside the table Get Record, Update and Display All Records are the buttons. All the user induced action in this applet is associated with these buttons. Below is the description of this action.

a) When the Get Record button is clicked the applet will retrieve the first record from the array of Record objects and will display the information in the corresponding textfields. Next time the Get Record button is clicked the second record from the array will be retrieved etc.

b) Immediately after the use of GetRecord the user will use the Update button. Before using Update the user is allowed to change information in all the textfields, except in the first textfield which contains the employeeId value. Then by clicking the Update button the user will send the information from the textfields into the array of Record objects. Before this operation the program will check that the numeric fields have correct information and will signal any errors.

c) At the end the user will click on the Display All Records button and the information stored in the array of Record objects will be displayed (one record per line) in the TextArea sorted by names in alphabetic order. Use Bubble Sort method for sorting. In the same time all the textfields are made empty.

At the end of the test write the content of the HTML file running this applet.

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

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions

Question

What is paper chromatography?

Answered: 1 week ago

Question

Explain the cost of capital.

Answered: 1 week ago

Question

Define capital structure.

Answered: 1 week ago