Solved-Assignment 1- | Human Resources Management System in FORTRAN and COBOL- Solution

$30.00 $19.00

Introduction In this assignment, you have to implement a system for processing employee attendance records. You are required to implement it once using FORTRAN and once using COBOL. Assignment Details 2.1 Company Attendance Record Processing Jimmy is designing a simple Human Resources Management System (the \System” hereafter) for the PPL corporation. He is asking you…

You’ll get a: . zip file solution

 

 

Description

5/5 – (2 votes)
  • Introduction

In this assignment, you have to implement a system for processing employee attendance records.

You are required to implement it once using FORTRAN and once using COBOL.

  • Assignment Details

2.1 Company Attendance Record Processing

Jimmy is designing a simple Human Resources Management System (the \System” hereafter) for the PPL corporation. He is asking you to implement the attendance tracking module of this system, which reads the employees’ daily attendance records, updates the monthly attendance records, and generates a daily attendance summary for the human resources manager.

The PPL corporation’s employees have to work from 10:00am to 5:00pm. Employees have to tap their smart sta card at the attendance reader when they arrive at work and depart after work respectively. They will be ned for being late for each 15-minute period in whole. For example, an employee will be ned for being 15 minutes late if he or she comes at 10:27am. On the other hand, the PPL corporation provides overtime work compensation. Every month, employees can claim at most 30 overtime working hours with proven attendance records. Only complete hours of overtime work are counted. For example, if an employee leaves work at 6:47pm, he or she can claim one hour of overtime work for that day.

The System keeps the employee data in a le: employees.txt. This le contains personal infor-mation of all employees. Each line of the le is an employee record, containing the sta number, name, gender, date of birth, hiring date, department and monthly salary of the employee. Also, the System keeps an employee monthly attendance summary: monthly-attendance.txt. This le contains the monthly attendance status of all employees. The rst line of this le contains the month information. In the rest of the le, each line contains the sta number, number of days absent, number of complete 15-minute periods being late, and the number of complete overtime work hours of an employee. Both les are sorted by the sta number in increasing order. The following is an example of the employees.txt and monthly-attendance.txt les.

employees.txt

1009CHAN

TAI MAN

M1992-01-012007-02-04ITD024320

1077WONG

ALICE

F1990-10-102007-02-04ITD020000

1823WONG

SIU MING

M1991-08-082007-02-04HRD015000

monthly-attendance.txt

2019-01

1009001002001

1077000000000

1823000002000

1

At every midnight, the System will generate one le: attendance.txt. This le contains all employee arrival/departure information recorded by the attendance reader on the previous day. The rst line of the le is the date information. If it is the rst day of the month, we need to reset the monthly attendance summary for all employees and also change the month information on the rst line of the le monthly-attendance.txt. The rest of the le contains one tapping record per line, which includes the sta number, status and tapping time of an employee. There are two possible statuses: ARRIVE and LEAVE. Records with ARRIVE statuses show the time of arrival for the corresponding employee. Records with LEAVE statuses show the time of departure. The attendance reader will mark all records before 5:00pm as ARRIVE and all records at or after 5:00pm as LEAVE. Records in this le will be sorted by the tapping time in chronological order.

Every employee should have one ARRIVE and one LEAVE record each day. If there is more than one ARRIVE record for the same employee, we handle only the rst ARRIVE record. Similarly, if there is more than one LEAVE record for the same employee, we handle only the rst LEAVE record. If an employee has either the ARRIVE or LEAVE records (but not both) missing, we should report the employee’s name to the human resources manager with the SUSPICIOUS status and should not update the monthly attendance summary for that employee. If an employee has no attendance records in a particular day, the employee is considered absent.

The following is an example of the attendance.txt le:

2019-01-04

1077ARRIVE2019-01-04-09:54

1823ARRIVE2019-01-04-09:55

1009ARRIVE2019-01-04-10:43

1077LEAVE 2019-01-04-18:45

1009LEAVE 2019-01-04-19:23

From the above example, we can see only sta 1009 was late for work, and would be penalized for being late for two counts of complete 15-minute periods. We report sta 1009 to the human resources manager with the LATE status. Also, we can see sta 1077 and 1009 worked overtime. They would be rewarded with one and two overtime working hours respectively. Moreover, we can see sta 1823 had only one ARRIVE record, we should report to the manager with the SUSPICIOUS status and not update the monthly attendance summary for sta 1823.

The System will also generate a daily summary for the human resources manager: summary.txt. The le consists of three parts. The rst part of the le gives the headers of the summary. The second part of the le contains the attendance summary for all employees. Each line contains the sta number, name, department and attendance status of an employee. The status can be PRESENT, LATE, ABSENT, or SUSPICIOUS. If an employee has no attendance records, the status should be ABSENT. If an employee has an ARRIVE record and one LEAVE record, the status should be PRESENT for those arriving on time or LATE for those arriving late. Otherwise, the status should be SUSPICIOUS. The last part of the le reports the occurrence of each status.

The following is an example of the summary.txt le based on the above example attendance.txt and employees.txt les,

Daily Attendance Summary

Date: January 4, 2019

Staff-ID Name Department Status

————————————————————–

1009

CHAN

TAI MAN

ITD

LATE

1077

WONG

ALICE

ITD

PRESENT

1823

WONG

SIU MING

HRD

SUSPICIOUS

————————————————————–

Number of Presences: 1

2

Number of Absences: 0

Number of Late Arrivals: 1

Number of Suspicious Records: 1

To sum up, you are required to implement a program to update the monthly attendance summary and generate a daily attendance summary based on the employee information and the daily atten-dance records. Your calculations should be based on the policy described above. Here is a diagram summarizing the relationship of all les.

Figure 1: Relationship of input and output les

2.2 General Speci cation

You are required to write two programs, one in FORTRAN and the other one in COBOL, for the attendance tracking module of the System. You should name your FORTRAN source as \atd.for” and your COBOL source as \atd.cob”.

  1. Input and Output Speci cation

Your programs should read three input les: employees.txt, attendance.txt, and monthly-attendance.txt, which contain employees’ information, daily and monthly atten-dance records. Your program should compute the number of complete 15-minute periods being late, number of complete overtime work hours, number of days absent, and the status of every employee. These calculations should be strictly based on the policy described above. Your program should output two les for updating the monthly attendance information and generating a summary for the human resources manager. The output les should follow the description in Section 2.4.

For FORTRAN, the name of the input les should be passed to your program as parameters in the command line:

./atd employees.txt attendance.txt monthly-attendance.txt

For COBOL, you should \hardcode” the name of the input les in your program EXACTLY as \employees.txt”, \attendance.txt” and \monthly-attendance.txt”.

The naming of output les should be as follows:

Output ASCII lenames for FORTRAN: monthly-attendancefor.txt, summaryfor.txt

Output ASCII lenames for COBOL: monthly-attendancecob.txt, summarycob.txt

  1. Restrictions on using FORTRAN and COBOL

In order to force you to program as in the old days, ONLY 2 keywords are allowed in

3

selection and loop statements: \IF” and \GOTO”. You are not allowed to use modern control constructs, such as if-then-else or while loop. Using any other keywords will receive marks deduction.

  1. Error Handling

The programs should also handle possible errors gracefully by printing meaningful error messages to the standard output. For example, failure to open a non-existing le. However, you CAN assume that the input les are free of errors.

  1. Good Programming Style

A good programming style not only improves your grade but also helps you a lot in debugging. Poor programming style will receive marks deduction. Construct your program with good readability and modularity. Provide su cient documentation by commenting your codes properly but never redundantly. Divide up your programs into subroutines instead of clogging the main program. The main section of your program should only handle the basic le manipulation such as le opening and closing, and subprogram calling. The main purpose of programming is not just to make the program right but also make it good.

  1. Other Notes

You are NOT allowed to implement your program in another language (e.g. Assembly/C/C++) and then initiate system calls or external library calls in FORTRAN and COBOL. Your source codes will be compiled and PERUSED, and the object code tested!

Do not implement your programs in multiple source les. Although FORTRAN and COBOL do allow you to build a project with subroutines scattered among multiple source les, you should only submit one source le for each language.

NO PLAGIARISM!!!! You are free to design your own algorithm and code your own implementation, but you should not \borrow” codes from your classmates. If you use an algorithm or code snippet that is publicly available or use codes from your classmates or friends, be sure to DECLARE it in the comments of your program. Failure to comply will be considered as plagiarism.

A crash introduction to FORTRAN and COBOL will be given in the upcoming tutorials. Please DO attend the tutorials to get a brief idea on these two languages, and then learn the languages by yourselves. For a more in-depth study, we encourage students to search relevant resources on the Internet (just Google it!).

2.3 Input File Format Speci cation

There are three input les: employees.txt, attendance.txt, and monthly-attendance.txt. All input les are in plain ASCII texts. Each line is ended with the characters \nrnn”. You should strictly follow the format as stated in the following.

The dates used in all les are speci ed by a string of the form: YYYY-MM-DD, where YYYY, MM, and DD represent a 4-digit year, a 2-digit month, and a 2-digit day respectively. If a month of a day has only one digit, start the number with zero. For example, the month of May is speci ed as \05″.

Each line of employees.txt contains eight elds of xed lengths of an employee.

    1. Sta number: a 4-digit string. If it is less than 1000, the left side of the number will be padded with zero(es).

    1. Last name: a string of length 10. If there are less than 10 alphanumeric characters in the name, spaces would be padded at the right side of the name.

    1. First name: a string of length 20. If there are less than 20 alphanumeric characters in the name, spaces would be padded at the right side of the name.

4

    1. Gender: a single character. It is always ‘M’ or ‘F’.

    1. Date of birth: a string of length 10. It is in date format.

    1. Hiring date: a string of length 10. It is in date format.

    1. Department: a string of length 3. It is an abbreviation of the department. It always consists of 3 capital letters.

    1. Monthly salary: a 6-digit string. It is between 0 to 999999. If it is less than 100000, the left side of the number will be padded with zero(es).

File attendance.txt is as follows. The rst line is the date in date format. The rest of the le contains three elds of xed lengths of a daily attendance record of an employee on each line.

    1. Sta number: a 4-digit string. If it is less than 1000, the left side of the number will be padded with zero(es).

    1. Status: a string of length 6. It is always \ARRIVE”, or \LEAVE”. If length of status is less than 6, spaces would be padded on the right side of the status.

    1. Time: a 16-character string of the form YYYY-MM-DD-HH:NN, where YYYY, MM, DD, HH, and NN represent a 4-digit year, a 2-digit month, a 2-digit day, a 2-digit hour, and a 2-digit minute. Time is written in 24-hour clock convention. If a 2-digit number is less than 10, there is a leading zero.

File monthly-attendance.txt is as follows. The rst line is month information, in YYYY-MM format, representing a 4-digit year and a 2-digit month. The rest of the le contains four elds of xed lengths of a monthly attendance record of an employee on each line. The number of lines in this le should be the same as that in the employees.txt le.

    1. Sta number: a 4-digit string. If it is less than 1000, the left side of the number will be padded with zero(es).

    1. Number of days of absent: a 3-digit string. If it is less than 100, the left side of the number will be padded with zero(es).

    1. Number of complete 15-minute periods being late: a 3-digit string. If it is less than 100, the left side of the number will be padded with zero(es).

    1. Number of overtime work hours: a 3-digit string. If it is less than 100, the left side of the number will be padded with zero(es).

You may make the following assumptions on the les:

All dates and times are valid.

Maximum number of employees is 9999.

File employees.txt is sorted by sta number in ascending order.

File attendance.txt is sorted by time in chronological order from the second line onward. File monthly-attendance.txt is sorted by sta number in ascending order from the second

line onward.

The timestamp of the rst attendance record in le attendance.txt is on or after YYYY-MM-DD-00:00, where YYYY-MM-DD is the date on the rst line of the same le.

The timestamp of the last attendance record in le attendance.txt is on or before YYYY-MM-DD-23:59, where YYYY-MM-DD is the date on the rst line of the same le.

Each line respects the description in this speci cation.

5

The following are examples of the input les.

employees.txt

1023CHAN TAI MAN M1992-01-012007-02-04ITD024320

1024WONG SIU MING M1993-11-112007-02-04ITD024320

1025A123456789B1234567890123456789F1993-11-112007-02-04ITD024320

1026PAN PETER M1993-11-112007-02-04HRD024320

attendance.txt

2018-09-29

1026ARRIVE2018-09-29-10:10

1023ARRIVE2018-09-29-10:28

1025LEAVE 2018-09-29-20:01

1026LEAVE 2018-09-29-20:01

1023LEAVE 2018-09-29-20:01

monthly-attendance.txt

2018-09

1023001000000

1024000001000

1025001011002

1026003000001

2.4 Output File Format Speci cation

There should be two output les, monthly-attendanceXXX.txt, summaryXXX.txt (XXX

  • for or cob), containing the updated monthly attendance summary and the daily attendance summary. Each line is ended with the characters \nrnn”. You should strictly follow the format as stated in the following.

File monthly-attendanceXXX.txt should have the same format as monthly-attendance.txt as described in Section 2.3. It should be sorted by sta number in ascending order from sec-ond line onward.

File summaryXXX.txt is as follows. The le contains three parts. { The rst part is the header of summary. It consists of four lines.

        1. The rst line is xed as \Daily Attendance Summary”.

        1. The second line is the date. It begins with \Date: “, followed by the date informa-tion, which is the same as the date information in attendance.txt. However, the date is written with month, day, and year in order with a comma before the year. Month is given in english. There are no leading zeroes. The date has length of 18. Space(s) is padded on the right of the date if needed. For example, \2018-01-02”

in attendance.txt becomes \January 2, 2018 ” in summary.txt.

    1. The third line is the eld header. It begins with \Staff-ID Name”, followed by 28 spaces, and followed by \Department Status”.

    1. The fourth line contains 62 \-“.

{ The second part is the attendance summary for all employees. Each line contains four elds of xed lengths of attendance summary. The number of lines in this le is the same as that in employees.txt. It should be sorted by sta number in ascending order.

    1. Sta number, Last name, First name, Department: same information and format from employees.txt, i.e. strings of length 4, 10, 20, 3, respectively, with zero(es)

6

or spaces padded if needed. Sta number, last name, and department are aligned with the eld headers Staff-ID, Name, and Department respectively. There is a space between last name and rst name.

    1. Status: a string of length 10. It is always \PRESENT”, \LATE”, \ABSENT”, or \SUSPICIOUS”. If the length of status is less than 10, spaces should be padded on the right of the status. It is aligned with the eld header Status.

{ The last part summerizes the occurrence of each status. It consists of ve lines.

    1. The rst line contains 62 \-“.

    1. The second line begins with \Number of Presences: “, followed by the number of sta with the \PRESENT” status.

    1. The third line begins with \Number of Absences: “, followed by the number of sta with the \ABSENT” status.

    1. The fourth line begins with \Number of Late Arrivals: “, followed by the num-ber of sta with the \LATE” status.

    1. The fth line begins with \Number of Suspicious Records: “, followed by the number of sta with the \SUSPICOUS” status.

    1. All numbers are of length 4. There are no leading zeroes. If a number is less than 1000, the left side of the number is padded with space(s).

Please make sure that each employee in employees.txt has a corresponding line in both the monthly-attendanceXXX.txt and summaryXXX.txt les.

The following is the content of the output les based on the sample input les given. monthly-attendanceXXX.txt

2018-09

1023001001003

1024001001000

1025001011002

1026003000004

summaryXXX.txt

Daily Attendance Summary

Date: September 29, 2018

Staff-ID Name Department Status

————————————————————–

1023

CHAN

TAI MAN

ITD

LATE

1024

WONG

SIU MING

ITD

ABSENT

1025

A123456789

B1234567890123456789 ITD

SUSPICIOUS

1026

PAN

PETER

HRD

PRESENT

————————————————————–

Number of Presences: 1

Number of Absences: 1

Number of Late Arrivals: 1

Number of Suspicious Records: 1

2.5 Report

You should give a simple report to answer the following questions within one A4 page:

  1. Compare the conveniences and di culties in implementing the attendance tracking module of the Human Resources Management System in FORTRAN and COBOL. You can divide

7

the implementation into speci c tasks such as \reading le in certain format”, \simulating loops”, \case control” and so on. Give code segments in your programs to support your explanation.

  1. Compare FORTRAN and COBOL with modern programming languages (e.g. Java/C++/…) from di erent aspects (e.g. paradigm, data type, parameter parsing, …). You are free to pick your favorite modern programming language.

  1. In your program design, how do you separate the tasks into submodules? Tell us brie y the functionality of each submodule and the main ow of your program in terms of these submodules.

  • Submission Guidelines

Please read the guidelines CAREFULLY. If you fail to meet the deadline because of submission problem on your side, marks will still be deducted. So please start your work early!

1. In the following, SUPPOSE

your name is Chan Tai Man,

your student ID is 1155234567,

your username is tmchan, and

your email address is tmchan@cse.cuhk.edu.hk.

  1. In your source les, insert the following header. REMEMBER to insert the header according to the comment rule of FORTRAN and COBOL.

/

CSCI3180 Principles of Programming Languages

— Declaration —

I declare that the assignment here submitted is original except for source material explicitly acknowledged. I also acknowledge that I am aware of University policy and regulations on honesty in academic work, and of the

disciplinary guidelines and procedures applicable to breaches of such policy and regulations, as contained in the website

http://www.cuhk.edu.hk/policy/academichonesty/

Assignment 1

Name : Chan Tai Man

Student ID : 1155234567

Email Addr : tmchan@cse.cuhk.edu.hk

/

The sample le header is available at

http://course.cse.cuhk.edu.hk/~csci3180/resource/header.txt

  1. Make sure you compile and run the FORTRAN program without any problem with f77 on Solaris (sparc machine).

  1. Make sure you compile and run the COBOL program without any problem with Open-COBOL 1.1 on Windows computers in SHB924/904. We will grade your works based on those machines.

  1. The report should be submitted to VeriGuide, which will generate a submission receipt. The report and receipt should be submitted together with your FORTRAN and COBOL codes in the same ZIP archive.

8

  1. The FORTRAN source should have the lename \atd.for”. The COBOL source should have the lename \atd.cob”. The report should have the lename \report.pdf”. The VeriGuide receipt of report should have the lename \receipt.pdf”. All le naming should be followed strictly and without the quotes.

  1. Tar your source les to username.tar by

tar cvf tmchan.tar atd.for atd.cob report.pdf receipt.pdf

  1. Gzip the tarred le to username.tar.gz by gzip tmchan.tar

  1. Uuencode the gzipped le and send it to the course account with the email title \HW1 studentID yourName” by

uuencode tmchan.tar.gz tmchan.tar.gz n

j mailx -s “HW1 1155234567 Chan Tai Man” csci3180@cse.cuhk.edu.hk

  1. Please submit your assignment using your Unix accounts.

  1. An acknowledgement email will be sent to you if your assignment is received. DO NOT delete or modify the acknowledgement email. You should contact your TAs for help if you do not receive the acknowledgement email within 5 minutes after your submission. DO NOT re-submit just because you do not receive the acknowledgement email.

  1. You can check your submission status at http://course.cse.cuhk.edu.hk/~csci3180/submit/hw1.html.

  1. You can re-submit your assignment, but we will only grade the latest submission.

  1. Enjoy your work :>

9