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

- The Timely Talent Temporary Help Agency maintains an employee master file that

ID: 3720961 • Letter: #

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's transaction file records to the master file and outputs one line for each transaction, indicating job number, employee ID number, hours worked, hourly rate, and gross pay. Assume that each temporary worker works at most one job per week. Output one line for each worker, even if the worker has completed no jobs during the current week. b. Modify the help agency program to output lines only for workers who have completed at least one job during the current week. C. Modify the help agency program so that any temporary worker can work any number of separate jobs during the week. Output one line for each job that week. d. Modify the help agency program so that it accumulates the worker's total pay for all jobs in a week and outputs one line per worker.

Explanation / Answer

(a)

start

            perform housekeeping( )

            while bothDone = "N"

                        perform mainLoop( )

            perform finishUp( )

stop

housekeeping( )

            declare variables

            open files

            perform readMaster( )

            perform readTrans( )

            if mId = 9999 then

                        if tId = 9999 then

                                    bothDone = "Y"

                        endif

            endif

return

readMaster( )

            read mRec

            if eof then

                        mId = 9999

            endif

return

readTrans( )

            read tRec

            if eof then

                        tId = 9999

            endif

return

mainLoop( )

            if mId < tId then

                        perform readMaster( )

            else

                        if mId = tId then

                                    print tJob, mId, tHours, mRate, tHours * mRate

                                    perform readMaster( )

                                    perform readTrans( )

                        else

                                    print "Employee", tId, "not in Employee Master file", tJob

                                    perform readTrans( )

                        endif

            endif

            if mId = 9999 then

                        if tId = 9999 then

                                    bothDone = "Y"

                        endif

            endif

return

finishUp( )

            close files

return

Flow Chart


b.)

Pseudo Code

start

            perform housekeeping( )

            while bothDone = "N"

                        perform mainLoop( )

            perform finishUp( )

stop

housekeeping( )

            declare variables

            open files

            perform readMaster( )

            perform readTrans( )

            if mId = 9999 then

                        if tId = 9999 then

                                    bothDone = "Y"

                        endif

            endif

return

readMaster( )

            read mRec

            if eof then

                        mId = 9999

            endif

return

readTrans( )

            read tRec

            if eof then

                        tId = 9999

            endif

return

mainLoop( )

            if mId < tId then

                        perform readMaster( )

            else

                        if mId = tId then

                                    print tJob, mId, tHours, mRate, tHours * mRate

                                    perform readTrans( )

                        else

                                    print "Employee", tId, "not in Employee Master file", tJob

                                    perform readTrans( )

                        endif

            endif

            if mId = 9999 then

                        if tId = 9999 then

                                    bothDone = "Y"

                        endif

            endif

return

finishUp( )

            close files

return

Flow Chart


d)

Pseudo Code

start

            perform housekeeping( )

            while bothDone = "N"

                        perform mainLoop( )

            perform finishUp( )

stop

housekeeping( )

            declare variables

            open files

            perform readMaster( )

            perform readTrans( )

            saveId = tId

            if mId = 9999 then

                        if tId = 9999 then

                                    bothDone = "Y"

                        endif

            endif

return

readMaster( )

            read mRec

            if eof then

                        mId = 9999

            endif

return

readTrans( )

            read tRec

            if eof then

                        tId = 9999

            endif

return

mainLoop( )

            if tId not = saveId then

                        print saveId, totalHours, saveRate, totalHours * saveRate

                        totalHours = 0

            endif

            if mId < tId then

                        perform readMaster( )

            else

                        if mId = tId then

                                    totalHours = totalHours + tHours

                                    saveId = tId

                                    perform readTrans( )

                        else

                                    print "Employee", tId, "not in Employee Master file", tJob

                                    perform readTrans( )

                        endif

            endif

            if mId = 9999 then

                        if tId = 9999 then

                                    bothDone = "Y"

                        endif

            endif

return

finishUp( )

            close files

return