The Timely Talent Temporary Help Agency maintains an employee master file that c
ID: 645078 • Letter: T
Question
The Timely Talent Temporary Help Agency maintains an employee master file
that contains an employee ID number, last name, first name, address, and hourly
rate for each temporary worker. The file has been sorted in employee ID number
order. Each week, a transaction file is created with a job number, address, customer
name, employee ID, and hours worked for every job filled by Timely Talent
workers. The transaction file is also sorted in employee ID order.
a. Design the logic for a program that matches the current week
Explanation / Answer
ResultSet rs = stmt.executeQuery("SELECT * FROM TransactionFile");
while(rs.next()){
int empID = rs.getInt('employeeId');
int jobNumber = rs.getInt('jobNumber');
int hoursWorked = rs.getInt('hoursWorked');
//till we get first employee record details in transaction
//now we are fetching emploee details from master using emploee id
ResultSet rs2 = stmt.executeQuery("SELECT * FROM Master where EmploeeId==empId");
while(rs.next()){
int hourlyRate = rs2.getInt('hourlyRate');
//calculate gross salary
int grossSalary = hourlyRate * hoursWorked;
System.out.println(jobNumber+","+empID+","+hoursWorked+","+grossSalary);
System.out.println(" ");//this is for new line...one record data in one line
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.