Answered step by step
Verified Expert Solution
Question
1 Approved Answer
can you fix the error in this? it does not save the entered start date. import java.io . * ; import java.util. * ; class
can you fix the error in this? it does not save the entered start date.
import java.io;
import java.util.;
class EmployeeRecordManagement
private Employee head;
Constructor
public EmployeeRecordManagement
head null;
done
private boolean recordExistsint id
Employee current head;
ifhead null
return false;
while current null && head null
if currentid id
return true;
current current.next;
return false;
done
public void insertString name, int id String startDate, String phoneNumber, String address, int workHours, double salary throws FileNotFoundException
Employee newEmployee new Employeename id startDate, phoneNumber, address, workHours, salary;
if head null
newEmployee.next head;
head newEmployee;
else
Employee current head;
while currentnext null && current.next.id newEmployee.id
current current.next;
ifhead current
newEmployee.next head;
head newEmployee;
else
newEmployee.next current.next;
current.next newEmployee;
System.out.println;
System.out.println Employee record added successfully.";
System.out.println
;
done
private void loadRecordsFromFile throws FileNotFoundException
File emp new FileEmployeeRecordtxt;
Scanner load new Scanneremp; this
ifempexists
whileloadhasNext
String name load.nextLine;
int id load.nextInt;
String startDate load.nextLine;
String phoneNumber load.nextLine;
String address load.nextLine;
int workHours load.nextInt;
double salary load.nextDouble;
load.nextLine;
insertnameidstartDate,phoneNumber,address,workHours,salary;
load.close;
done
private void saveRecordsToFile throws IOException
Employee current head;
File emp new FileEmployeeRecordtxt;
FileWriter save new FileWriteremp;
while current null
save.writeName: current.name
ID: current.id
"Start date: current.startDate
"Phone number: current.phoneNumber
"Address: current.address
"Work hours: current.workHours
"Salary: current.salary
;
current current.next;
save.close;
done
public int deleteint id
Employee current head;
Employee temp null;
if current null && current.id id
head current.next;
return ;
while current null && current.id id
temp current;
current current.next;
if current null
return ;
temp.next current.next;
return ;
public void updateEmpint id
Scanner update new ScannerSystemin;
Employee current head;
String name, startDate, phoneNumber, Address;
int workHours, again choice;
double Salary;
ifrecordExistsid
System.out.println;
System.out.println The employee with ID id is not found";
System.out.println;
else
whilecurrent null
ifcurrentid id
break;
current current.next;
do
System.out.p
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started