Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
image text in transcribed
image text in transcribed
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 system into companents (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 nocrihla mumm.-. Qefining the stnut ure of the arogrom. For a simple problem like this that processes a set of records, we have a main unit and several sub-units each of which performs a specific function. Each record is opened in the 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. Flow 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: Dption 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, (i) 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: computoHours Description: Reads five float numbers from a specilied input stream, performs necessary data validation and computes the sum. If data is valid, returns the sum; returns 1 otherwise. Parometers: Input stream (from which the numbers of hours for each of the five days is read.) Return walue: A float value (that gives the sum of the five numbers read.) Alganithm: Initialize total to O; 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 stage. 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 g) 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 get the data. 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

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions

Question

=+ Have they changed the way employers view IP?

Answered: 1 week ago