Module 1 Page 12-41
Module 1 Page 12-41
1. Program Specification
2. Program Design
3. Program Coding
4. Program Testing and Debugging
5. Program Documentation
6. Program Maintenance
Program
Specification
Program
Program Design
Maintenance
Program
Program Coding
Documentation
Program
Testing and
Debugging
12 | P a g e
Program Background – This specifies the nature of the program,
background information, programming language to be used, and the
target dates.
The available input – These are the given data which will be
manipulated so that the required output may be obtained.
The Required Output – This is what the program intends to do, including
the desired output layout and specifications.
2. Program Design is the way you plan a solution, preferably using a structured
programming technique. The technique consists of the following:
Example:
Example:
Let’s have a look at this code at the left column and see the Pseudo Code for the
same at the right column.
13 | P a g e
// This program calculates the Lowest Common multiple This program calculates the Lowest Common
// for excessively long input values multiple
for excessively long input values
import java.util.*;
function lcmNaive(Argument one, Argument
public class LowestCommonMultiple {
two){
private static long
lcmNaive(long numberOne, long numberTwo) Calculate the lowest common variable of
{ Argument
1 and Argument 2 by dividing their product
long lowestCommonMultiple; by their
Greatest common divisor product
lowestCommonMultiple
= (numberOne * numberTwo) return lowest common multiple
/ greatestCommonDivisor(numberOne, end
numberTwo);
}
function greatestCommonDivisor(Argument
return lowestCommonMultiple;
one, Argument two){
}
if Argument two is equal to zero
then return Argument one
private static long
greatestCommonDivisor(long numberOne, long numberTwo)
{ return the greatest common divisor
if (numberTwo == 0) end
return numberOne; }
return greatestCommonDivisor(numberTwo,
numberOne % numberTwo); {
} In the main function
public static void main(String args[])
{ print prompt "Input two numbers"
Logic Structures are the ways or techniques on how statements are organized
or represented to show the logic of the program. There are three logical
structures: sequence, selection, and iteration. These shall be further discussing
in Module 4 of this course.
14 | P a g e
There will be further discussion on the flowchart in the last part of this Module.
Top-down program design are steps called program modules to identify the
program’s processing steps which are made up of logically related program
statements.
Example:
Master
Payroll
Compute Compute
Salary Deduction
3. Program Coding. Coding is the actual writing of the program logic using any
programming language.
Methods of Testing: Desk checking, manual testing, and testing sample data
on the computer. In these phases, programs are tested through the use of
computers and undergo special systems software such as Language
Translator. Symbolic and high-level programming languages have translators
that will tell the programmer if the language has been used correctly. The job
of a language translator is to convert a source code ( a program written in a
15 | P a g e
particular programming language) into its object code (machine code)
equivalent.
16 | P a g e
developer. It continually modifies ore revises to cope with changes and
ensure that current programs are operating error-free, efficiently, and
effectively. If bugs occur even when the program is running smoothly for
some time, the programmer must be able to trace and correct the errors.
Until now, the theory of problem-solving (Newell and Simon, 1972) has mainly
emphasized the search for solutions within a problem space. From this viewpoint,
problem-solving capability (intelligence) should be seen as the possession of
adequate logic, which allows the search more efficient.
Definition of Terms
IPO Chart is also known as Input- Process-Output Chart. IPO links the Input and
Output and specifies what input data go into a process and what output is generated
as an outcome.
17 | P a g e
Example of an IPO Chart:
Let’s test your learning by answering our second quiz. Good luck!
18 | P a g e
Quiz #1.2
Good Luck!
Assessment
“First, solve the problem. Then, write the code.” – John Johnson
I. Identification
______________ 1. The name of input data which may be in a form of facts or figures
which will be manipulated throughout the program.
______________ 3. Any violation of the rules and regulations such as wrong spelling or
missing punctuation marks while writing the program code.
_______________ 4. One of the steps in program development that specifies the given
data, required outputs, and program processing requirements.
_______________ 5. Method of program testing which uses special system software that
translates high-level language into its low level language equivalent.
_______________ 9. Among the different kinds of translator, this converts the program
source code into its equivalent object code on a line-by-line basis.
19 | P a g e
______________ 11. Step in programming development which focus on the actual
coding and translate the program plan into a programming language.
______________ 12. The updates were done to the program to correct errors and to
improve the usability, as well as to standardized and adjust to organizational changes.
______________ 13. One of the major reasons why planning is important before doing
the program which considers the welfare of the end-users.
______________ 14. A technique in planning stage which uses symbols to illustrate data,
information, and its workflow.
20 | P a g e
Problem Analysis
Program Plan
The first step is to define the problem. In this step, the problem is examined
carefully to determine what questions must be answered before attempting to solve
the problem. From this sub-step, the required output of the program is determined.
The second step is to assemble all given data and to assign variable names to
those quantities, which are unknown. All unnecessary information should be discarded
because many problems contain information that has no meaning to the solution.
From this sub-step, the available data are derived.
The third step is to discover relationships among data and to express the
relationship as an equation. The quotations are also arranged in order of importance
so that the proper sequence of the solution may be determined. From this sub-step,
the processing requirements are determined.
Create a program plan that will compute for an employee’s weekly net pay
and will generate the employee’s payslip similar to the one below:
Payroll Period
September 7 – 12, 2020
The payroll period, employee name, regular hours worked, and overtime hours
rendered is to be entered from the keyboard. Overtime pay is one and a half times
the regular rate, while tax is set at 15% of the gross.
21 | P a g e
Solution:
Program Plan
a. Available input
1. Payroll Period = period
2. Employee Name = EName
3. Regular Hours Worked = RHWorked
4. Regular Rate per Hour = RRate
5. Overtime Hours Rendered = OHRendered
b. Processing Requirements
1. Net Pay = Gross Pay – Tax
2. Gross Pay = Basic Salary of the Week + Overtime Pay
3. Tax = Gross Pay * .15
4. Basic Salary = RHWorked * RRate
5. Overtime Pay = OHRendered * RRate * 1.50
c. Required output
Payroll Period
MM –DD-YYYY
Algorithm
After the instructions to enter the input items, the next set of instructions
process the input typically by performing some calculations on some processing
items. Processing items represent an intermediate value that the algorithm uses
when processing the input into the output. These steps are entered in the processing
column of an IPO chart. The algorithm usually end with an instruction either to print
or to display or to store the output items which are listed in the Output column of the
IPO chart.,
22 | P a g e
Algorithm (Sample Problem 1-1)
Problem: Print the sum of the two (2) numbers.
Algorithm:
1. Input the first number
2. Input the second number
3. Compute for the SUM by adding the first number to the second number.
4. Print the SUM
Now, let us create an IPO chart using the example above that would create a
program plan that will compute for an employee’s weekly net pay and will generate
the employee’s payslip based on the specifications provided.
The following algorithm can be used to compute for the weekly net pay of an
employee:
1. Enter period, EName, RHWorked, RRate, and OHRendered
2. Multiply RHWorked and RRate, call it as salary
3. Multiply RRate with 1.50, name it as 0Rate
4. Multiply RHWorked with 0Rate, call it as 0pay
5. Add salary and 0Pay, name it as Gross
6. Multiply Gross with 0.15, call it as Tax
7. Subtract Tax from Gross, name it as Net
8. Display Pperiod, Ename, RHWorked, RRate, BSalary, OHRendered, 0Pay, Gross,
tax, and Net
Solution:
The following are helpful hints a programmer may consider in planning an algorithm.
1. Before writing an algorithm, consider whether you have already solved a similar
problem if so, you can use the same solution with little modification to solve the
current problem.
23 | P a g e
2. If you have not yet solved a similar problem, consider whether you can use a
portion of an existing algorithm to solve the current problem to save time and
effort and use it to a more serious, needs a deeper examination of the
program.
3. If both items 1 and 2 are not considered, then solve the problem manually,
noting each step you take to do so.
Instruction: Create a program plan and an algorithm for the following cases:
A man knows that the gasoline tank of his car holds 24 gallons and that his car
averages 18.3 miles per gallon. He starts with a full tank and drives at 45 miles per hour.
Find the volume of the gasoline left in the tank at any given time.
PROGRAM PLAN
Required Output The volume of the gasoline left in the tank
Algorithm
Step 1. Start
Step 2. Enter time (t)
Step 3. To obtain the average gasoline consumption at any given time, multiply amg
by (t), call it as (Avgt)
Step 4. To obtain the volume consumed, divide the car’s speed by AVGt, name it as
(V3)
Step 5. To compute the remaining gasoline, subtract (V2) from (V1), call it as
(VRemaining)
Step 6. Stop
Let’s test your learning by accomplishing our lecture activities. Good luck!
24 | P a g e
Good Luck!
Assessment
1.1 Suppose you want to create a program that would accept any number
and computes the square, and square root the number read.
PROGRAM PLAN
Required Output
Available Input
Processing Requirements
Algorithm
25 | P a g e
1.2 Input three (3) integer numbers, then calculate and output their sum
and the average.
PROGRAM PLAN
Required Output
Available Input
Processing Requirements
Algorithm
26 | P a g e
1.3 A store owner wants to give a 10% discount to customers who are 60
years old and above.
PROGRAM PLAN
Required Output
Available Input
Processing Requirements
Algorithm
27 | P a g e
Lecture Activity # 2 – Design Tools (Algorithm)
Instructions: Create a program plan and algorithm for the following case and write
your answer on the table provided.
A company pays an annual bonus to its employees. The bonus is based on the
number of years the employee has been with the company. Employees working at
the company for less than 5 years receive a 1% bonus while the rest will receive a 2%
bonus. Bonuses will also be based on the employee’s annual salary.
PROGRAM PLAN
Required Output
Available Input
Processing Requirements
Algorithm
28 | P a g e
Lecture Activity # 3 – Design Tools (Algorithm)
Instructions: Create a program plan and algorithm for the following case and write
your answer on the table provided.
A company pays an annual bonus to its employees. The bonus is based on the
number of years the employee has been with the company. Employees working at
the company for less than 5 years receive a 1% bonus while the rest will receive a 2%
bonus. Bonuses will also be based on the employee’s annual salary.
PROGRAM PLAN
Required Output
Available Input
Processing Requirements
Algorithm
29 | P a g e
Flowchart and Flowcharting Symbols
SYMBOL FUNCTION
30 | P a g e
SYSTEM FLOWCHART SYMBOLS
SYMBOL FUNCTION
Predefined Process or Subroutine. Used to denote a
sequence of steps that are separate from the main
flowchart.
Printer. Used to print results, reports, or messages.
Read N
M=1
F=1
F=F*M
M = M=1 Is
M = N?
Print N
End
31 | P a g e
processing activities. This flowchart is used to show in general terms what is to
be accomplished by the program.
Begin
Begin
Print Heading
Compute Pay
Print Cheque
End
The main difference between the system flowchart and program flowchart is
that a system flowchart explains the functionality of an entire system while a
program flowchart explains how a single program solves a given task.
There are some basic shapes and boxes included in flowcharts that are used
in the structure of explaining the steps of algorithms. Knowing how to use them while
drawing flowcharts is crucial. Here are some rules that should be known:
1. All boxes of flowcharts are connected with arrows to show the logical
connection between them,
2. Flowcharts will flow from top to bottom,
3. All flowcharts start with a Start Box and end with a Terminal Box.
32 | P a g e
Example 1: Create a program that will calculate the Interest of a Bank Deposit
Algorithm:
Flowchart:
Example 2: Create a program that will determine and output whether Number N is
Even or Odd
Algorithm:
33 | P a g e
Flowchart:
Algorithm:
Flowchart:
34 | P a g e
Example 4: Determine Whether A Student Passed the Exam or Not:
Algorithm:
Flowchart:
35 | P a g e
Good Luck!
Assessment
d = ½ gt2
PROGRAM PLAN
Required Output
Available Input
Processing Requirements
36 | P a g e
Algorithm
Flowchart
37 | P a g e
Lecture Activity # 5 – Design Tools (Flowchart)
Instruction: Create a program plan, algorithm, and a flowchart for the following case:
Design the algorithm for a program that calculates the current balance in a savings account.
The program should obtain from the user the following information: the starting balance, the total
amount of deposits made, the total amount of withdrawals made, and the monthly interest rate.
After the program has calculated the current balance, it should be displayed on the screen. Assume
one input for deposits and one input for withdrawals. Draw the flowchart for this algorithm.
PROGRAM PLAN
Required Output
Available Input
Processing Requirements
Algorithm
38 | P a g e
Flowchart
39 | P a g e
Lecture Activity # 6 – Design Tools (Flowchart)
Instruction: Create a program plan, algorithm, and a flowchart for the following case:
Design the algorithm for a program that calculates the total of a retail sale.
The program should ask the user for the following: the retail price of the item being
purchased and the sales tax rate. Once the information has been entered the
program should calculate and display the following: the sales tax for the purchase
and the total sale. Draw the flowchart for this algorithm
PROGRAM PLAN
Required Output
Available Input
Processing Requirements
Algorithm
40 | P a g e
Flowchart
41 | P a g e
References:
https://www.yourdictionary.com/programming
http://www.scribd.com/doc/7368548/Logic-Formulation
http://au.answers.yahoo.com/question/index?qid=20071110191353AABcdvH
http://wiki.answers.com/Q/What_are_the_logic_formulation
https://www.computerhope.com/jargon/m/machlang.htm#:~:text=Machine%20lan
guage%20example,the%20text%20%22Hello%20World.%22&text=Below%20is%20anot
her%20example%20of,times%20to%20the%20computer%20screen.
https://www.computerhope.com/jargon/a/al.htm#:~:text=Programs%20written%20i
n%20high%2Dlevel,JavaScript%2C%20Clojure%2C%20and%20Lisp.
https://www.britannica.com/technology/fourth-generation-language
https://www.geeksforgeeks.org/differences-between-procedural-and-object-
oriented-programming/
https://www.geeksforgeeks.org/how-to-write-a-pseudo-code/
https://www.computertaleem.com/problem-
analysis/#:~:text=changes%20before%20completion.-
,Problem%20Analysis%20in%20Computer%20programming%20is%20the%20process%2
0where%20we,discussed%20for%20giving%20the%20solution.
https://pediaa.com/what-is-the-difference-between-system-flowchart-and-
program-
flowchart/#:~:text=The%20main%20difference%20between%20system,flowchart%20r
epresents%20a%20single%20program.&text=One%20such%20diagram%20is%20a,mo
del%20to%20a%20given%20problem.
42 | P a g e