Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Case study: Developing a payroll program for a small business. Consider a small business that needs a program to process its weekly payroll. Each week,

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Case study: Developing a payroll program for a small business. Consider a small business that needs a program to process its weekly payroll. Each week, a data file consisting of payroll records with the following format is generated: 20 character name > An example of a payroll record is shown below. Joseph, John axp15 9580413.503 The program has to generate a printout that describes each employee's pay stub. Each pay stub record has the following format: For the above example, the pay stub will be as follows: Joseph, John axp15 26351.0035.10315.90 The business has formulas for how to compute the total number of hours, how to compute the total salary and how to compute the withholding. In addition, the program must also do some data validation. The numbers for the hours worked should all be between 0 and 16 ; otherwise the output should flag an error. The business would like the program to be such that changes can be easily incorporated. The error handling may need changes and the formulas used may vary from time to time, so it should be possible to modify these easily. It should also be possible to make changes to the format of the output. How would you go about designing a program to accomplish this? Your design should (i) describe all the functional units and (ii) explain how the functional units will interact to accomplish the required task. Also, how does your design allow for the kinds of changes described above to be easily incorporated? Creating a software solution When we have a more complex problem like this, a more sophisticated problem solving process is needed. In addition to the kind of analysis, design and implementation that we have seen earlier, our solution must provide us with some additional things like: (i) A framework for the solution (ii) A top-down decomposition of the systern into components (iii) A development process Anolyzing the Problem When dealing with more complex systems, the first step in analysis is to make sure that we have an understanding of the problem domain. In our case, the problem domain is payroll needs of a small business. Using common knowledge and the information given above, we can see that the input is a record for each employee, which provides us with several pieces of data; using these pieces, some information about the payable salary is calculated. The steps are as follows: - Step 1. Compute the hours worked for the week. The data needed for this is the number of hours worked on each day, which will have to be read from the input. The appropriate formula for this will be provided to us. The output of this step will be a single number representing the total hours. - Step 2. Compute the total salary for the week. The data needed will be the total number of hours, which was computed in Step 1, and the hourly wage, which will be part of the input. The output will be an amount representing the gross salary of the employee. - Step 3. Compute the amount of withholding for the week. The data needed for this is the total salary and the number of deductions that the employee has. The output will be an amount. representing the amount of money to be withheld from the week's paycheck. - Step 4. Compute the net salary for the week. The data needed will be the gross salary, which was computed in Step 2, and the withholding, which was computed in Step 3. The output will be an amount representing the net salary of the employee. Defining the test cases. Following the idea of test-driven development our next task is to develop the test cases. A name and id are needed for each record; for Step 1, we need the hours worked for each day. As discussed before, the test cases should check all possible outcomes. Defining the structure of the orogram. For a sain and several sub-units each of which performs a specific function. Each record is opened have a main unit and several main unit. The main unit then passes the control to each of the sub-units in sequence; each subunit returns the result of the computation to the main unit. The control finally returns to the main unit, which starts processing the next record. The next step in the process is to define all the functional sub-units. Since there are several operations listed in the requirements, for which the business would like to incorporate changes at a later point. It is therefore prudent to encapsulate each of these in a separate functional unit. We can therefore identify the following components in our system: 1. A main unit that interacts with user, opens the input and output files, initiates the processing of each record, and passes the control to the sub-units as needed. 2. Separate units to handle each of the tasks, especially the ones that may change: a. to compute the total number of hours b. to compute the total salary c. to compute the withholding d. to produce the output in a specified format. Each of these units performs the necessary tasks and returns the result to the main unit. Flaw of control between main program and the subprograms. A decision we need to make is: in which part of the program should we read the data? Before we define the sub-units, we have to decide how the data will be made available to the sub-units. We have two options: Option 1. The main program reads all the data for each record and then passes the relevant data to each sub-unit. Option 2. The main program passes the input stream to the sub-units so that each sub-unit directly. reads the data. Option 1 can be a good choice when the input format is such that all the data fields are not conveniently arranged. Option 2 comes in handy when the input format is conveniently arranged, and we need a quick-and-easy solution. Option 2 can be problem if the input format is not suitably arranged so that each sub-unit can read the input stream independently. We will apply Option 2 since it is sufficient for our purpose. Defining the functions. For each function, we will define the following: (i) Name of the function, (ii) What parameters it has, and what each parameter means (iii) What it computes, i.e., what output it produces. (iv) If necessary, the algorithm used to do the computation. Using the above format, here is definition of the function for computing the total hours: Nome: computelhours Description: Reads five float numbers from a specified input stream, performs necessary data validation and computes the sum. If data is valid, returns the sum; retums 1 otherwise. Parometers: input stream (from which the numbers of hours for each of the five days is read.) Return wafue: A fioat value (that gives the sum of the five numbers read.) Algorithm: Initialize total to 0 ; in a loop, read each number, validate it, and add it to the total. Designing, Implementing and Testing the Solution The design is done in a top-down fashion in multiple stages. In the first stage, we design the structure of the main unit and the output unit. In each subsequent stage, we design and implement one more functional unit. Thus in each stage, new functionality is added to the program and is verified for correctness. The first stoge. The design for the first stage is the algorithm for the main unit. Since we are using the "pipelined" framework for our program, the overall process used by the main program is as follows: 1) Open the data file. 2) Open the output file 3) Try to read a name 4) While (another name was read) a) Read the id b) Compute the total hours c) Compute the total salary d) Compute the total withholding e) Compute the net salary f) Write the output B) Try to read a name 5) Close the files. The second stage. The design for the second stage is for the sub-unit that computes the total hours. To compute the total hours, we need to read the hours for each day; the program will access the input file to In subsequent stages, we compute total salary, total withholding and so on. See CourseFiles for all the stages of the program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

Students also viewed these Databases questions

Question

2. What are the three major versions of monism?

Answered: 1 week ago