Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This class will contain six data fields and methods to set, get and manipulate these fields. You must reate an array of Employee objects, populate

This class will contain six data fields and methods to set, get and manipulate these fields. You must reate an array of Employee objects, populate and display the values. You will not be changing your class, but you will have to submit it.

The method

Construct a method called createEmployeeArrayFromFile(). This method will create and return an array of Employee objects.

Hard code the file name, (example)________, into your program. The file will contain six lines for each employee: an employee number, name, department, position, salary, and rank and has data for 10 employees.

Construct the array. There will be ten of these and this can be hard coded. Although we are reading this information from a file and it would be more useful to simply add objects as we go along, an array needs a size when it is created. (The ArrayList class does not, and is preferable in this respect, but we will stick to an array.)

Create a loop and iterate through the file, creating elements of the Employee array. If you didnt know how much data was stored in the file, you would use a while loop, but since you know it will contain exactly 10 employees, you can use a while loop or for loop.

Finally, the method must return the array.

printEmployeeArray()

Create a void method called printEmployeeArrray() that takes one parameter, an Employee array. Loop through the array and print the values using the Employee objects displayEmployee() method.

The main method

Empty the main method. Create an Employee array variable and make it equal to the createEmployeeArrayFromFile() method call. Then call the printEmployeeArray() method and send it one argument: the Employee array.

You should know:

If you use a while loop to iterate through the file, you will need an int variable to act as an index for the array. Make sure to initialize this variable to 0 before the loop begins and increment it within the loop.

You may encounter the nextLine issue as you read through the file. This occurs when you read a number using nextInt or nextDouble and then use the nextLine method. This is remedied by using a dummy nextLine call in between nextInt and nextLine.

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

Question

1. Design an effective socialization program for employees.

Answered: 1 week ago