Chapter 4 – Design Tools: Jackson Structured Programming (JSP)

Topics: Vector space, Output, Condition number Pages: 3 (2133 words) Published: November 3, 2014
4.1 Three Structured Constructs All programs can be constructed using only the three basic constructs. It is the concept of structured programming that a program should be developed using only these three basic constructs. It is not wrong to use the GOTO structure but it is discouraged, because programs with the GOTO structure are often classified as unstructured. The three basic constructs are Sequence Selection Iteration/Repetition 4.1.1 Sequence Construct In a sequence construct, the way the statements are placed implies the order in which the computer will execute the statements. The computer will interpret the statements in a left to right, top to bottom fashion. Consider the following Calculate-Average Module DO Get Two Numbers Calculate Sum Determine Average Print Average ENDDO The sequence for the above module is straightforward. You get the two numbers, calculate the sum, determine the average and print out the result. If the statements are not in that sequence, the result obtained will not be the answer intended Figure 4-1 Simple sequence The Calculate Average module is not a separate module away from the rest of the four modules below it. But it actually contains all the four modules. Each process (a rectangle) represents a component with their function/action stated in the function list. If the component does not contain or form other constructs (i.e. other sequences, selections or iterations), it is regarded as an elementary component. The diagram should be interpreted in a top-down, left to right manner. The Calculate-Average Module has four elementary components. Each time it is activated, it will activate the Input Number module, Calculate Sum module, Determine Average module and the Print Result module in that order. Consider another example Figure 4-2 Complex sequence The sequence of activation for the above will be A, B, E, F, C, D, G, I, J, H 4.1.2 Selection Construct The selection construct consists of condition(s) and one or...