You are on page 1of 13

Copyright 2009 All rights reserved

JERRY ESPERANZA

Objective
The module was designed to achieve the following; 1. Identify flowcharting symbols. 2. Use flowchart symbols in identifying steps/pseudocode in logic formulation. 3. Formulate flowchart solutions. The material used a problem-direct solution approach. Instead of defining each flowchart symbol first, we applied it on situation when we need it and define it on the sidelines. What covered on this material are program flowcharts. System flowcharts are designed to show interface between input/output devices, to other systems, and the program itself. It uses other specialized symbols which are beyond the coverage of this courseware. Though new tools are being introduced in software development, flowcharting is still one of the effective tools in presenting the logic/idea of program execution. Students of Computer Science or related IT courses will benefit on this courseware as one prepares career as Scientist, Analyst, Programmer or Project Manager. We encourage everyone to give us feedback on how you find this material so we may improve it. You may reach us at thrivingJerry@yahoo.com. Visit also our blogsite: http://ThrivingAndLiving.blogspot.com .

About the Author


Jerry Esperanza is a Computer Science professor. He has more than 7 years experience teaching at Jose Rizal University (JRU) and currently at New Era University (NEU), Philippines. He worked as Administrative Specialist at IBM Philippines, Inc. and served as a Technical Support Engineer at ETSI Technologies, Inc. (A Siemens Nokia joint ventured company) for ten years. He was a Database Marketing Analyst for a year at OSRP (a PCMall.com company) and as Analyst at Business Intelligence Group of eTelecare Global Solutions for another couple of years. He holds a bachelor degree in Computer Engineering at Polytechnic University of the Philippines (PUP) and currently working on his thesis for a masters degree in Educational Management at New Era University Graduate Studies. As a registered professional teacher, he believes that a teacher is behind in anyone who excels. Continuous education is one of his advocacies to uplift human understanding and condition.

http://ThrivingAndLiving.blogspot.com

Flowcharting as Algorithm Tool


Algorithm is a step-by-step procedure in solving a problem. It may be expressed in a human language, pseudocode (not a real code), and/or with flowcharts. Flowchart is the graphical representation of the algorithm. Problem A gives emphasis on how to convert step-by-step tasks into a flowchart. Terminal is mandatory symbol used in all flowcharting activities. There is only one set of start and end terminal symbols in flowcharting an algorithm. It is strictly enforced to use an arrow head at the end of the flow lines. It helps to know which direction the flowchart is heading. Process box denotes action. Problem A. Design a flowchart from the given tasks: 1. Plug in computer power cords to the Uninterruptable Power Supply (UPS). 2. Switch on UPS. 3. Push the power-on button of the PC. 4. Enter username and password in the Microsoft XP login dialog. Solution:
Start

* Plug in computer power cords to the UPS.

Terminal symbol is required to use at start and end of flowchart * Flowline indicates the direction of the next instruction or sequence of available information and executable operation. It is used with an arrow at the end to denote direction.

Switch on UPS.

Push the poweron button of the PC.

Process Box represents the process of executing a defined or group operations that result in a change value, form or location of information.

Enter username and password in the Microsoft XP login dialog.

End

http://ThrivingAndLiving.blogspot.com

Decide which path to take


Problem B gives us a dose on how to deal with decision. The diamond symbol represents a condition normally answered by yes or no, true or false. A path is taken and determine the next step to do depending on the answer set by the condition. Problem B. Design a flowchart from the given traffic procedure: 1. Slow down at intersection. 2. Check traffic light signal. 3. If signal = green 3.1 Continue driving. Solution 1
Start

4. If signal = red 4.1 Press brake. 5. If signal = yellow 5.1 Prepare to stop.

Slow down at intersection.

* Decision box branches to the next instruction depending on the result of condition. ** On-page connector used to direct at the next instruction WITHIN the page. Label it either by letter or number or combination of both.

Check traffic light signal.

* Signal = green? **

Continue driving. C

Signal = red?

Press brake.

Signal = yellow?

Prepare to stop.

N
C End

http://ThrivingAndLiving.blogspot.com

Solution 2 We can solve the same problem using a different approach. No need to test if the signal is yellow. We can logically assume that if it is not green, two conditions would remain: either red or yellow. Green is tested first; red next. Therefore, neither green nor red, we proceed immediately to step when the color is yellow. Thus, we eliminate the condition of testing yellow.

Start

Slow down at intersection.

Check traffic light signal.

Signal = green?

Continue driving. C

Signal = red?

Press brake.

N
Prepare to stop.

End

http://ThrivingAndLiving.blogspot.com

Initialize your Storage


Algebra uses literals (x and y variables) in solving an equation. In programming, variables or identifiers are treated as memory storage. We need to name (and initialize) it at the start of every program. Just like in an algebraic equation, the value of these identifiers varies as the execution of the program progresses. Problem C introduces the use of initialization or preparation symbol. Parallelogram is also used specifically to signify process dedicated either to input or output tasks. Problem C. Design a flowchart from the given arithmetic operations: 1. Initialize x with 3; y with 4; z with 0. 2. Add x and y and store it at z. 3. If z < 10 3.1 Display Sum is less than 10. Solution`

Start

x=3 y=4 z=0

Initialization or preparation stores the start value of identifiers or variables at the start of the program

z= x+y

z < 10

Display Sum is less than 10

N
End

Input/Output box used as an I/O function which makes data available for processing (input) or displaying (output) of processed information.

http://ThrivingAndLiving.blogspot.com

Break Large Task into Small Tasks


We may run not just into steps but series of steps. This would be a dilemma for programmers and analysts if they are working on larger systems. It would hard for them to contain the problem if something goes wrong. One way to avoid this kind of situation is to modularize inter-related tasks into one package. Solution for Problem D shows how flowcharting approaches modularization. It has a main program that jumps into subtasks (addNumbers/subtractNumbers) and returns to the calling program (main) after execution. Subtasks are smaller programs within a program. That is why it starts and ends with terminal symbols. Instead of the START/END texts inside these terminal symbols, the name of subtask is indicated; RETURN signals the end of the execution within subtask and returns to the calling program. Problem D. Design a flowchart with two modules set. 1. addNumbers. 2. subtractNumbers. addNumbers: 1.1 Initialize x and y with zero. 1.2 Enter number and store to x. 1.3 Enter number and store to y. 1.4 Add 1 to y. 1.5 Add y to x. 1.6 Print the value of x. subtractNumbers: 2.1 Initialize z with -4. 2.2 Subract 1 to z. 2.3 If z < -4 2.3.1 Add 2 to z. else 2.3.2 Subract 1 to z. 2.4. Print the value of z.

Solution:
Start

*
addNumbers

* Predefined process box represents a named process consisting of one or more operations or program steps that are specified elsewhere.

subtractNumbers

End

http://ThrivingAndLiving.blogspot.com

addNumbers A

x=0 y=0

y= y+1

Accept x

x= x+1

Accept y

Print the value of x.

RETURN

subtractNumbers

z = -4

z <-4

Y
z=z+2

N
z=z-1 z=z-1

1
Print the value of z.

Off-page connector is used to direct the next instruction located on ANOTHER page. Label it either by letter or number or combination of both. Page 1

RETURN

Page 2

http://ThrivingAndLiving.blogspot.com

Connectors used on loops


We can see on the solution of Problem E how connectors are utilized in doing repetitive tasks. Connectors are best applied when loops occur in the program. Problem E. Design a flowchart from the given pseudocode: 1. Initialize identifiers start with 1; finish with 4. 2. if start < 4 2.1 Display value of start. 2.2 Add 1 to start. 2.3 if finish > 0 2.2.1 Display value of finish. 2.2.2 Subtract 1 to finish. 2.2.3 Proceed to 2.3 2.4 Store 4 to finish. 2.5 Proceed to 2. 3. Display value of start. 4. Display value of finish. Solution
Start A

start = 1 finish = 4
C

Display value of finish

finish = finish - 1 start < 4

Display value of start B

N
Display value of finish

start = start + 1

B Display value of start Y finish> 0 A N End finish = 4 C

http://ThrivingAndLiving.blogspot.com

Common Flowcharting Error


1. Hanging process. This is a common error where the designer left process or predefined box hanging and does not specify the next task to do. Use may use flow lines or connectors to correct this problem.

green?

Y Continue driving. green? Continue driving. N C

NO!

YES

2. Decision box with three-outgoing branch. You may notice from other textbooks the use of 3-outgoing branch. Because this material is used as introduction to programming, stick with the use of 2-outgoing branch for now. The decision box on this case is designed only to answer conditions with YES or NO; TRUE or FALSE.

MAYBE She loves me?

YES She loves me?

YES

NO

NO

NO!

YES

http://ThrivingAndLiving.blogspot.com

10

3. Too many end terminal symbols. Flowchart designers who are lazy to route the next step to END often create more than one terminal symbol. Remember always that you are only allowed to have one set of START/END terminal symbols in a flowchart. Again, you may correct this error by using flow lines or connectors.

Signal = green?

Y Continue driving.

Signal = green?

Y Continue driving.

End N N

Signal = red?

Y Press brake.

Signal = red?

Y Press brake.

N A

End

End

NO!

YES

http://ThrivingAndLiving.blogspot.com

11

Problem Exercises
I. Design a flowchart based from the given tasks. Problem A. Initialize x and y with value 0. Store 10 to x. Store -3 to y. if y<x 4.1 Display x is greater than y 4.2 Display value of x. 5. Display value of y. 1. Initialize age with a value of 0. 2. Accept age. 3. if age<18 3.1 Print Minor: you cannot vote. 4. if age >= 18 4.1 Print Your age is eligible to vote. 5. if age >= 65 5.1 Print Senior Citizen: Vote wisely. Our future is at stake. Initialize num with value 0. Display Enter a number. Accept num. if num>0 4.1 Display Number is positive. else 4.2 if num<0 4.2.1 Display Number is negative. else 4.2.2 Display Number is origin. 5. Display value of num. 1. Initialize inputGrade and grade with value 0. 2. Accept inputGrade. 3. if inputGrade <= 100 3.1 if inputGrade >= 98 3.1.1 grade = 1.0 4. if inputGrade <= 97 4.1 if inputGrade >= 95 4.1.1 grade = 1.25. 5. if inputGrade <= 94 5.1 if inputGrade >= 91 5.1.1 grade = 1.5. 6. if inputGrade < = 90 6.1 if inputGrade >= 89 6.1.1 grade = 1.75. else 6.2.1 if inputGrade <= 88 and inputGrade >= 86 6.2.1.1 grade = 2. else 6.2.1.2 grade = 5. 7. Print the value of grade. 12 1. 2. 3. 4. 1. 2. 3. 4.

Problem B.

Problem C.

Problem D.

http://ThrivingAndLiving.blogspot.com

II.

Formulate your own flowchart that will solve the following problems.

1. Show steps on how to withdraw money from ATM. Include situation of what to do when machine captures your ATM card. 2. Design a modularize approach of how to convert Celcius to Farenheit temperature and vice versa. The user enters a temperature and later asked on what temperature conversion will it make. Compute and display the converted temperature value. Use the following formula in conversion: Celcius = 5/9 * (Farenheit -32) Farenheit = 9/5 * Celcius + 32 3. Write a flowchart that will display message Programming is fun! 10 times. Your flowchart should be flexible enough to handle change of number of times the message is displayed: you only need to change the value 10 into either 5, 15, 100 or 1000 and nothing more.

http://ThrivingAndLiving.blogspot.com

13

You might also like