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

This assignment involves creating a program to track employee information. Keep

ID: 3801607 • Letter: T

Question

This assignment involves creating a program to track employee information. Keep the following information on an employee:

1. Employee ID (string)

2. Last name (string)

3. First Name (string)

4. Birth date (string as MM/DD/YYYY)

5. Gender (M or F, single character)

6. Start date (string as MM/DD/YYYY)

7. Salary per year (double)

Thus you must create a class that has all of this, and get/set methods for each of these fields.

Your class must have three constructors:

1. No arguments. Just construct an object.

2. Takes only an employee ID

3. Takes all information When the program starts it must check to see if a file called Employee.txt exists. If it does, read the information into Employee objects which you dynamically allocate and put them into an array of pointers to objects. Data in the file is stored separated by spaces, one employee per line. Assume the company will have no more than 100 employees, but if it does, show an error. No vectors for this one.

The program will have a menu that shows the following options:

1. Enter new employee information. When the ID is entered, make sure that ID is not in use for another employee. Request the rest of the info and create a new Employee object.

2. Display all employee information in alphabetical order. The list may not have been entered in order, but you must sort it to display it. Show the information in fixed-field columns so that it looks neat. Show the salary to the nearest dollar.

3. Look up an employee by ID. If the ID exists, show all of the information. If not, display a message.

4. Remove an employee. This should delete the object pointer from your array and remove the Employee object from memory. (How do you handle this in the array?) 5. Save all data to Employee.txt and exit. Invalid menu options will display a message and return to show the menu.

After executing options 1 through 4, return to the menu. The Employee class will not have a method to write all of the employees to the file, since it does not know about more than one employee at a time. However, you will have a method to write them all out, with each piece of data separated by a comma and one employee per line.

Explanation / Answer

public class Employee {
String lastName = null;
String firstName = null;
double ID;

public Employee(String lastName, String firstName, double ID){
this.lastName = lastName;
this.firstName = firstName;
this.ID = ID;
}

public String empStat(){
return "Last Name: " + lastName + "First Name: " + firstName + "ID" + ID;
}

}
public class MainEmployee {
public static void main(String args[]){

Employee nub1 = new Employee ("good", "sasi", 000001);
System.out.println(nub1);
Employee nub2 = new Employee ("Good", "ganga", 000002);
System.out.println(nub2);
Employee nub3 = new Employee ("Good", "Satya", 000003);
System.out.println(nub3);
Employee nub4 = new Employee ("Good", "sai", 000004);
System.out.println(nub4);


}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote