You are on page 1of 11

Designing The Algorithm

An algorithm is a general solution of a problem which can be written as a verbal description of a precise, logical sequence of actions. Cooking recipes, assembly instructions for appliances and toys, or precise directions to reach a friend's house, are all examples of algorithms. A computer program is an algorithm expressed in a specific programming language. An algorithm is the key to developing a successful program. Suppose a business office requires a program for computing its payroll. There are several people employed. They work regular hours, and sometimes overtime. The task is to compute pay for each person as well as compute the total pay disbursed. Given the problem, we may wish to express our recipe or algorithm for solving the payroll problem in terms of repeated computations of total pay for several people. The logical modules involved are easy to see.
Algorithm: PAYROLL

Repeat the following while there is more data: get data for an individual, calculate the pay for the individual from the current data, and, update the cumulative pay disbursed so far, print the pay for the individual. After the data is exhausted, print the total pay disbursed.

Figure 1.5 shows a for our task. This is a layered diagram showing the development of the steps to be performed to solve the task. Each box corresponds to some subtask which must be performed. On each layer, it is read from left to right to determine the performance order. Proceeding down one layer corresponds to breaking a task up into smaller component steps -- a refinement of the algorithm. In our example, the payroll task is at the top and that box represents the entire solution to the problem. On the second layer, we have divided the problem into two subtasks; processing a single employee's pay in a loop (to be described below), and printing the total pay disbursed for all employees. The subtask of processing an individual pay record is then further refined in the next layer. It consists of, first reading data for the employee, then calculating the pay, updating a cumulative total of pay disbursed, and finally printing the pay for the employee being processed. The structural diagram is useful in developing the steps involved in designing the algorithm. Boxes are refined until the steps within the box are ``doable''. Our diagram corresponds well with the algorithm developed above. However, this type of diagram is not very good at expressing the sequencing of steps in the algorithm. For example, the concept of looping over many employees is lost in the bottom layer of the diagram. Another diagram, called a flow chart is useful for showing the control flow of the algorithm, and can be seen in Figure 1.6. Here the actual flow of control for repetitions is shown explicitly. We first read data since the control flow requires us to test if there is more data. If the answer is ``yes'' we proceed to the calculation of pay for an individual, updating of total disbursed pay so far, and printing of the individual pay. We then read the next set of data and loop back to the test. If there is more data, repeat the process, otherwise control passes to the printing of total disbursed pay and the program ends.

From this diagram we can write our refined algorithm as shown below. However, one module may require further attention; the one that calculates pay. Each calculation of pay may involve arithmetic expressions such as multiplying hours worked by the rate of pay. It may also involve branching to alternate computations if the hours worked indicate overtime work. Incorporating these specifics, our algorithm may be written as follows:
Algorithm: PAYROLL

get (first) data, e.g., id, hours worked, rate of pay while more data (repeat the following) if hours worked exceeds 40 (then) calculate pay using overtime pay calculation otherwise calculate pay using regular pay calculation

calculate cumulative pay disbursed so far print the pay statement for this set of data get (next) data

print cumulative pay disbursed

The algorithm is the most important part of solving difficult problems. Structural diagrams and flow charts are tools that make the job of writing the algorithm easier, especially in complex programs. The final refined algorithm should use the same type of constructs as most programming languages. Once an algorithm is developed, the job of writing a program in a computer language is relatively easy; a simple translation of the algorithm steps into the proper statements for the language. In this text, we will use algorithms to specify how tasks will be performed. Programs that follow the algorithmic logic will then be easy to implement. Readers may wish to draw structural diagrams and flow charts as visual aids in understanding complex algorithms. There is a common set of programming constructs provided by most languages useful for algorithm construction, including:

: test a condition, and specify steps to perform for the case when the condition is satisfied (True), and (optionally) when the condition is not satisfied (False). This construct was used in our algorithm as:
if overtime hours exceed 40 then calculate pay using overtime pay calculation otherwise calculate pay using regular pay calculation

: repeat a set of steps as long as some condition is True, as seen in:


while new data repeat the following ...

or print data from/to peripheral devices. Reading of data by programs is called data input and writing by programs is called data output. The following steps were used in our algorithm:
read data write/print data, individual pay, disbursed pay

Languages that include the above types of constructions are called and include such languages as C, Pascal, and FORTRAN. A program written in an algorithmic language must, of course, be translated into machine language. A Utility program, called a , translates source programs in algorithmic languages to object programs in machine language. One instruction in

an algorithmic language, called a , usually translates to several machine level instructions. The work of the compiler, the translation process, is called compilation. To summarize, program writing requires first formulating the underlying algorithm that will solve a particular problem. The algorithm is then coded into an algorithmic language by the programmer, compiled by the compiler, and loaded into memory by the operating system. Finally, the program is executed by the hardware.

Example Program: Payroll System


Project Brief Design a program that will accept as data input the hours worked and the hourly rate of an employee and calculates the overtime pay and gross pay. The program should display the hours worked, the net pay and the gross pay. Employees are paid time and a half for any hours worked over the basic forty. A structure chart has been developed for this system, showing the payroll system calling three procedures. Each procedure is numbered in the hierarchy. This general layout follows the idea of Input, Process and Output.

PayrollSystem Data Table


The data table for PayrollSystem is shown below:

Identifier HoursWorked HourlyRate OvertimePay OvertimeHours GrossPay BasicHours

Description Hours worked by the employee Hourly rate of pay Pay at time and a half for hours over 40 Total overtime hours (Local to Mod Ref 2) Total pay before tax Normal weekly hours worked of 40

Type/Range Integer Real Real Integer Real Integer Constant

Algorithm (Detailed Design)


The detailed design for the algorithm is shown below:

Module 0 - PayrollSystem Begin Call GetPayDetails Using HoursWorked, HourlyRate Call CalcPayroll Using HoursWorked, HourlyRate, OvertimePay, GrossPay Call DisplayPayroll Using HoursWorked, HourlyRate, GrossPay End Module 1 GetPayDetails Begin Display 'Please enter the hours worked: ' Get HoursWorked Display 'Please enter the hourly rate of pay: ' Get HourlyRate End Module 2 CalcPayroll Begin If (HoursWorked is greater than 40) Then Begin { If } Calculate OvertimeHours as HoursWorked - BasicHours Calculate GrossPay as (BasicHours * HourlyRate) + (OvertimeHours * 1.5 * HourlyRate) End { If } Else Begin { Else } Calculate GrossPay as (HoursWorked * HourlyRate) End { Else } End Module 3 DisplayPayroll Begin Display GrossPay End

DisplayPayslip CalcPayroll GetHourlyRate GetHoursWorked

SALARY PROCESS Attendance : 1. Daily attendance should be maintained by the Admin officers of the concerned outlet. While the staff signing the attendance the Admin staff / Security staff must be present. The staff those who absents more than two days to be intimated to the HOD/Admin/HR department for disciplinary action. Ekkattuthangal & Ambattur : Attendance should be signed at the Security In gate. The grace time is fifteen minutes, By sharp 9.45am the attendance register will be taken inside and to be signed infront of the Admin Officer. Admin officer is required to maintain the attendance on daily basis for the ON THE JOB TRAINEES. Ekkattuthangal : After the grace time is over the attendance register will be at Admin Dept Ms Anitha is responsible for this outlet. Ambattur : After the grace time is over the attendance register will be at Admin Dept Mr Kalyanasundaram is responsible for this outlet. Kilpauk Show room : Since there is no security person to maintain the attendance, Mr Rajendran Admin officer should be present in the morning while staff signs the attendance sheet, after the grace time, the sheet will be taken inside to GM Sales for his information. Daily attendance sheet should be preserved and the same is to be maintained in the prescribed form of Attendance Register. By 25th of every month Admin Officer of all outlets should close the attendance forward to the Admin Manager for verification. By 26th all attendance sheets duly signed by the Admin Manager and the concerned Unit head to submit to the HR department. The attendance sheets without the signature of the Unit head and the Admin manager will not be accepted.

Service Ekkattuthangal & Ambattur GM Service Sales - Kilpauk Showroom - GM Sales Finance & Accounts - Sr. Manager Finance Admin dept - Admin Manager HR - HR Manager Security & Housekeeping - Admin Manager EDP - EDP Manager Trainees & OJTs - GM Service 2. Staff who avail permission, later comers, leave letters of all staff should be maintained in Admin department. During the crosschecking, the statement should be available. The staff who do not produce leave letters will be considered as absent and the leave will not be adjusted and the salary for these days will not be paid. Approved leave letters should be produced. 3. Admin dept is required to close the attendance on 25th of every month and the attendance sheets photo copy should be forwarded duly signed by the Admin Manager and the Unit Head / Dept Head. 4. Attendance details of Ambattur (including OJTs ), Kilpauk & Ekkattuthangal should reach HR department on 26th of every month without fail. 5. HR will cross check the attendance. Deductions : The deductions list should be duly signed and be forwarded to HR as per the details below : HR to 1. Deductions for Late coming, Absenteeism, Permission Should be approved by the Head of the department 2. Salary deductions for disciplinary actions, Hold salary list should be approved by HOD, should reach HR on or before 26th of every month. Accounts dept : Sr. Manager Finance or Manager Accounts duly signed The list with the name of the staff, employee code number, location, amount to be deducted should be clear 1. Salary Advance list 2. Loan 3. TDS Income tax purpose 4. Tour advance 5. Any other advance / Debits Admin to : Uniform deductions : The New joinees those who are all issued uniform should be deducted Rs 500/- against uniform deposit. Those below the rank of Assistant Managers will be deducted uniform deposit. Uniform issued list to be received from the Admin department duly signed by the Admin Manager. The deducted amount will be reimbursed after six months completion in the

organisation, no separate receipt will be issued for this deduction, it will reflect in the Payslips. Additional Payments : 1. The Fixed conveyance list approved by MD ( HR has a copy) No separate voucher for the local conveyance will be encouraged, the purpose of this fixed conveyance is those who travel on duty to visit our other outlets on duty. 2. Incentives list approved by HODs all types of incentives Performance based incentive Referral Incentive ( Executive cadre) - the staff who refer the candidates for recruitment, the referrer will be paid a sum of Rs 1000/ on completion of first month by the new joinee, after completion of 90 days in company rolls will be released the remaining balance of Rs 1000/For staff catergory Rs 500 + 500 in two instalments For technician category Rs 750 + 750 3. Increment letter / approval from the Director / MD HR department : Salary is processed in a Payroll software which is recently installed. 1. Master copy of the salary sheet, should be duly approved by the Director 2. Every month New joinees & Left employees to be updated before starting the payroll for the current month. Details will be checked by 1. Department attendance summary by HOD 2. All Branch attendance by Admin Manager 3. Cross check the salary statement by HR dept with previous months statement. 4. Submission of the salary statement to Accounts dept for checking. 5. Finally, after checked by the Accounts dept. to be submitted to Director. 6. Final report will be signed off by the Director STEPS IN CALCULATING SALARY: Leave Record : Leave balance should be updated, LEAVE BALANCE AS ON 31.5.09 (SHOW ROOM) S.NO CODE NAME DESIGNATION GROSS SALARY BL COM OFF BL. CL COM OFF CL TOT

BAL LEAVE LOP WORKED DAYS Eligiblitoy : Casual leave - 7 days per year Sick leave - 5 days per year Totally 12 days eligible one day per month Privilege / Earned Leave : The staff who completes one year will become eligible for this Each 20 days of completion one EL is eligible ( while calculation number of Holidays of previous year, Sundays, Absent days to be kept in mind) Opening balance of previous month Eligibility of leave Total number of days leave availed current month LOSS of pay for current month Provide the LOP details to HODs and get that approved Calculate salary based on available LOP details given by HODs Add conveyance amount in Bank statement which will be given to Accounts department Prepare Pay Slip in duplicate copies and get that signed from individual employees. Payment : The salary statement should be bifurcated into the following : 1. Credit in the staffs bank account 2. Cheque will be prepared in the name of the staff whose salary is above Rs 5000/3. Staff salary Below a sum of Rs 5000/- will be paid by cash. 3 Cash disbursement : 1. Salary disbursement : Ambattur Mr Mohan Manager (Accounts) Kilpauk _ Mr S. Sukumar ( Accounts) Ekkattuthangal Mr R. Venkatesan ( Accounts) 2. Documents required for various branches. Salary statement, salary slip 3. HR to monitor on daily basis, the total number of unpaid salary covers, amount, name of the staff etc., 4. The balance unpaid salary covers, amount disbursed should be recorded.

Check List : 1. Attendance sheets All outlets 2. Approved list of Employee master Print out 3. Supporting documents of Increments 4. Deductions list - Loan, salary advance, TDS, phone, any other deductions 5. Attendance summary approved list ( Duly signed by Admin & HOD)

6. Approved Hold list from all departments 7. Any other specific approval 8. Print our of Leave register. 9. Fixed conveyance approved list 10. Incentives approved list. Narender Malik
Subject - Re: HR payroll flow chart

Hi We Are leading Payroll Software Firm we deal in payroll accouting erp etds softwares To evolve as a world class software service company and pursue promising emerging technologies to rollout solutions successfully based on cutting edge technologies. We have developed vide range of customized products Payroll Management System Income Tax Software Income Tax E filing software Mini ERP Software Accounting software Inventory Software Production Planning Software Billing Softwares Website Design and Maintenance Other Customized Products We transform the business capability of our clients, by combining proven expertise in technology and skills in harnessing the knowledge of selected industries and business processes. We provide the state-of-the-art technology solutions that range from enterprise solutions to Internet applications. We already have clients like Cultural Ministry, Electrolux Kelvinator Ltd., Hotel Le Meridien, EPC Global, Studds, Bhayana Builders, Far Horizon, Lanco Infratech, Sahara Global, and many more............. We can can capture your requiremnts and customizations

more at http://www.citehr.com/167517-hr-payroll-flowchart.html#ixzz1WaXUGhgd

You might also like