Professional Documents
Culture Documents
EDP-Algorithm Development
EDP-Algorithm Development
EVENT-DRIVEN
PROGRAMMING
Module 1.2 – Algorithm Development
1
313
ITEC
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
Module Objectives
01
Learn about the steps involved in the Program Development Cycle
02
Use Pseudocode Statements and Flowchart Symbols in solving
programming problems
03
Learn about modularizing a program and its advantage
2
04
Learn about structuring and modularizing unstructured logic
313
ITEC
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
REMINDERS
• Please take the pre-test prior to studying the module (to be
submitted but score will not be recorded)
• Do the learning exercises after studying each objective.
• Take the post test after you finish studying the whole module. (to
be submitted and score will be recorded)
• Mark the activities done from the checklist found on the Learning
Plan section of your module
• Submit the exercises and post test on time
• Deadline: Must be submitted within 10 days
• Grace period: 4 days after the deadline but will be
marked as late
• Submit your activities to the following platform:
• High-Level Tech: CSPC LeOns
• Medium-Level Tech: CSPC LeOns / Gmail / Messenger
• Low-Level Tech: Drop off your activities to the designated
module pick-up points near you
313
ITEC
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
Objective 1:
Understanding Program
Development Cycle
A programmer’s job involves writing
instructions, but a professional programmer
usually does not just sit down at a computer
keyboard and start typing. A programmer’s
4
job involves the steps in a program
development cycle.
313
ITEC
PAGE 01
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
Program Development Cycle
It is the process of developing a software, according to the
desired needs of a user, by following a basic set
of interrelated procedures. It includes various set of
procedures and activities that are isolated and sequenced
for learning purposes but in real life they overlap and are
highly interrelated.
5
Figure 1-1
313
ITEC
PAGE 02
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
STEPS IN PROGRAM DEVELOPMENT CYCLE
UNDERSTAND THE Professional programmers write programs to satisfy the needs of others,
PROBLEM called users or end users. Because programmers are providing a service to
these users, programmers must first understand what the user wants.
This is the most critical part of the program development cycle. User may
not really know what they want, and users who think they know frequently
change their minds after seeing sample output.
PLAN THE LOGIC The heart of the programming process wherein the programmer plans the
steps of the program, deciding what steps to include and how to order
them. It includes thinking carefully about all the possible data values a
program might6 encounter and how you want the program to handle each
scenario. When planning program, programmers call it as developing an
algorithm.
CODING THE PROGRAM Programmers chooses a particular languages because some have built in
capabilities that make them more efficient than others at handling certain
types of operations. The logic developed to solve a programming problem
can be executed using any number of languages.
313
ITEC
PAGE 03
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
STEPS IN PROGRAM DEVELOPMENT CYCLE
USING A SOFTWARE TO Even though there are many programming languages, each computer
TRANSLATE THE PROGRAM knows only one language—its machine language, which consists of 1s
INTO MACHINE LANGUAGE and 0s. When you learn the syntax of a programming language, the
commands work on any machine on which the language software has
been installed. However, your commands then are translated to
machine language, which differs in various computer makes and
models.
313
Figure 1-2
ITEC
PAGE 04
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
STEPS IN PROGRAM DEVELOPMENT CYCLE
TESTING THE A program that is free of syntax errors is not necessarily free of logical
PROGRAM errors. A logical error results when you use a syntactically correct statement
but use the wrong one for the current context. Once a program is free of
syntax errors, the programmer can test it—that is, execute it with some
sample data to see whether the results are logically correct. It is the process
called debugging. You debug a program by testing it using many sets of
data.
PUTTING THE Once the program is thoroughly tested and debugged, it is ready for the
PROGRAM INTO organization to use. Putting the program into production might mean simply
PRODUCTION running the program once, if it was written to satisfy a user’s request for a
special list. However, the process might take months if the program will be
run on a regular basis, or if it is one of a large system of programs being
developed.
MAINTAINING THE After programs are put into production, making necessary changes is called
PROGRAM maintenance. Maintenance can be required for many reasons: for example,
because new tax rates are legislated, the format of an input file is altered, or
the end user requires additional information not included in the original
output specifications.
313
ITEC
PAGE 05
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
TRY AND LEARN
ACTIVITY 1 - Essay
313
ITEC
PAGE 06
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
Objective 2:
Using Pseudocodes
Statements and Flowcharts
PROGRAMMING IS DIFFICULT (like other useful and
worthwhile tasks — and like most of those tasks, it can be
satisfying and enjoyable too). You have to tell the machine
every little detail about what to do when you write a
program. So, you've got to get it right, because the machine
will follow your program blindly just as it's written. How,
then, are people writing any programs but 10the simplest?
Actually, it's not a big mystery. This is a matter of finding the
best way to think.
313
ITEC
PAGE 07
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
Pseudocodes and Flowcharts
313
ITEC
PAGE 08
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
Pseudocode Statements
Using pseudocode involves writing down all the steps you will use in
a program. It is fairly flexible because it is a planning tool, and not the
final product. Therefore, for example, you might prefer any of the
following:
• Instead of start and stop, some pseudocode developers would use
other terms such as begin and end.
313
ITEC
PAGE 09
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
Pseudocode Statements
313
ITEC
PAGE 10
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
Flowcharts
Some professional programmers prefer writing
pseudocode to drawing flowcharts, because using
pseudocode is more similar to writing the final
statements in the programming language. Others
prefer drawing flowcharts to represent the logical flow,
because flowcharts allow programmers to visualize
more easily how the program statements will connect.
For beginning programmers, flowcharts 14
are an
excellent tool to help them visualize how the
statements in a program are interrelated.
313
ITEC
PAGE 11
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
FLOWCHART SYMBOLS
Defines the starting and ending point of a flowchart.
Manipulation of data.
313
ITEC
PAGE 12
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
FLOWCHART SYMBOLS
16
313
ITEC
PAGE 13
PAGE 14
PSEUDOCODE
FLOWCHART
EXAMPLE
AND
EXAMPLE
FLOWCHART
AND
313
ITEC
PAGE 17
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
USING SENTINEL TO END A
PROGRAM
313
ITEC
PAGE 18
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
USING SENTINEL TO END A
PROGRAM
313
ITEC
PAGE 19
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
USING THE CONNECTOR
You can use a connector when limited
page size forces you to continue a
flowchart in an unconnected location or
on another page.
313
ITEC
PAGE 20
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
TRY AND LEARN
ACTIVITY 2 - Logic Exercise
313
ITEC
PAGE 21
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
Objective 3:
MODULES
Programmers seldom write programs as one
long series of steps. Instead, they break down
their programming problems into smaller units
and tackle one cohesive task at a time.
These smaller units are modules.
3 reasons:
• it provides abstraction.
• allows multiple programmers to work on a problem.
• allows you to reuse your work more easily.
313
ITEC
PAGE 22
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
MODULARIZATION
▪ MODULARIZATION PROVIDES ABSTRACTION
– Abstraction – process of paying attention to important properties while ignoring
nonessential details.
• Example:
With abstraction: Without abstraction:
- Do laundry - Pick up laundry basket
- Call Aunt Nan - Put laundry basket in car
- Start term paper - Drive to Laundromat
- Get out of car with basket
- Walk into Laundromat
- Set basket down
- Find quarters for washing machine
- … and so on.
313
ITEC
PAGE 23
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
MODULARIZATION
▪ IT ALLOWS MULTIPLE PROGRAMMERS TO WORK ON A
PROBLEM
▪ When you dissect any large tasks into modules, you gain the ability to
more easily divide the tasks among various people.
313
ITEC
PAGE 24
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
MODULARIZATION
▪ IT ALLOWS YOU TO REUSE YOUR WORK EASILY
▪ if a module is useful and well-written, you may want to use it more
than once within a program or in other program.
313
ITEC
PAGE 25
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
MODULARIZING A PROGRAM
Most programs consists of main program, which contains
the basic steps or the mainline logic of the program.
Module includes:
▪ HEADER – includes module identifier and possibly other
necessary identifying information.
▪ BODY – contains all the statements in the module.
▪ RETURN STATEMENT – marks the end of the module and
identifies the point at which control returns to the program or
module that called the module.
313
ITEC
PAGE 26
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
MODULARIZING A PROGRAM
• Rules in naming modules:
▪ Module names must be one word and start with a letter.
▪ Module names should have some meaning.
▪ Module names are followed by a set of parentheses
The flowchart symbol used to call a module is a rectangle with a bar across the top.
313
ITEC
PAGE 27
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
MODULE’S HEADER
MODULE’S BODY
MODULE’S RETURN
STATEMENT
313
ITEC
PAGE 28
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
MODULARIZING A
PROGRAM EXAMPLE
Program that produces a bill using only
main program
313
ITEC
PAGE 29
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
MODULARIZING A
PROGRAM EXAMPLE
Program that produces a bill using main
program that calls displayAddressInfo()
313
module
ITEC
PAGE 30
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
TRY AND LEARN
ACTIVITY 3 – LOGIC EXERCISE
A. P lan t h e lo g i c f o r a p r o g r am t h at c alc u lat e s a p e r s o n ’ s
b ody mas s i n de x ( B M I ) . B M I i s a s t at i s t ic al me as u r e t h at
c omp ares a p e r s o n ’ s we i g h t an d h e i g h t . T h e p r o g r am u s e s
th ree modu le s . T h e f i r s t p r o mp t s a u s e r f o r an d ac c e p t s t h e
u s er’ s h ei g h t i n i n c h e s . T h e s e c o n d mo du le ac c e p t s t h e u s e r ’ s
wei gh t i n p o u n ds an d c o n v e r t s t h e u s e r ’ s h e i g h t t o me t e r s
an d wei gh t to k i lograms . Th en , i t c alc ulates B M I as wei gh t i n
k i lograms t i me s h e i g h t i n me t e r s s qu ar e d an d di s p lay s t h e
res u lts . Th e r e ar e 2 .54 c e n t i me t e r s i n an i n c h , 1 00
c en ti mete r s i n a me t e r , 453 .59 g r ams i n a p o u n d, an d 1 , 000
grams i n a k i lo g r am. T h e las t mo du le di s p lay s t h e me s s ag e
34
E n d of th e j o b .
B. R evi s e t h e B M I - de t e r mi n i n g p r o g r am t o e xe c u t e
c on ti n u ou s ly u n t i l t h e u s e r e n t e r s 0 f o r t h e h e i g h t i n i n c h e s .
313
ITEC
PAGE 31
Objective 4:
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
STRUCTURING AND MODULARIZING
UNSTRUCTURED LOGIC
Steps to structure the dog-washing process
313
ITEC
PAGE 32
STRUCTURING AND MODULARIZING
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
UNSTRUCTURED LOGIC
Structured dog-washing flowchart and
pseudocode
313
ITEC
PAGE 33
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
STRUCTURING AND MODULARIZING
UNSTRUCTURED LOGIC
Modularized version of the dog-washing
program
313
ITEC
PAGE 34
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
TRY AND LEARN
ACTIVITY 4 – LOGIC EXERCISE
Each of the flowchart segments below is
unstructured. Redraw each segment so that it
does the same thing but is structured.
38
313
ITEC
PAGE 35
COLLEGE-CCS DEPT.
CAMARINES SUR POLYTECHNIC
THANK YOU!
Make sure to finish and submit your activities
on time. Review your Module 1.2 on how to do
and submit it.
313
ITEC
PAGE 36