0% found this document useful (0 votes)
80 views

Topic 3 - Problem Solving Organization

The document discusses tools for organizing problem solving on computers, including problem analysis charts (PAC), structure charts, input-process-output (IPO) charts, algorithms, and flowcharts. It provides examples of using a PAC to analyze a problem of calculating employee gross pay based on hours worked and pay rate. The PAC breaks the problem into given data, required results, processing required, and solution alternatives. It also shows developing a structure chart to divide the gross pay calculation into modules for reading data, calculating pay, and printing results.

Uploaded by

Vimala Vim
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views

Topic 3 - Problem Solving Organization

The document discusses tools for organizing problem solving on computers, including problem analysis charts (PAC), structure charts, input-process-output (IPO) charts, algorithms, and flowcharts. It provides examples of using a PAC to analyze a problem of calculating employee gross pay based on hours worked and pay rate. The PAC breaks the problem into given data, required results, processing required, and solution alternatives. It also shows developing a structure chart to divide the gross pay calculation into modules for reading data, calculating pay, and printing results.

Uploaded by

Vimala Vim
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 38

ICT1101

PROGRAM LOGIC
FORMULATION
Topic 3: Problem Solving Organization
[email protected]
2020
Learning Outcomes
• List and describe the basic tools used to aid in the development of a solution to a
problem:
• Problem Analysis Chart (PAC)
• Structure Chart or Interactivity Chart
• IPO Chart
• Algorithms
• Flowcharts
• Data Dictionary
• Describe the categories of documentation
Communicating with the Computer
• A computer needs instructions governed by specific rules.
• If instructions are incorrect, it can result in errors, the wrong answer or no
answer at all.
• Terms:
• Syntax – Rules that govern the computer operating system, language and application.
Bug – Errors that can come from syntax or logic errors.
• Debugging – Act of finding and correcting bugs
• Goal: Solve problem with the most efficient solution.
Organizing the Solution
• Organizational tools can help to solve problems
on the computer.
• Steps:
• Analyze the problem – PAC
• Divide problem into subtasks/modules – Interactivity chart
• Identify inputs, processes and outputs – IPO chart
• Develop the algorithm
• Draw the flowchart
Analyzing the Problem (PAC)
• The problem analysis chart (PAC) divides a problem into four parts:

Given Data Required Results


Data given in the problem or provided by Requirements for the output reports.
the user. These can be known values or This includes the information needed
general names for data (E.g. price, and the format required.
quantity, etc.)
Processing Required Solution Alternatives
List of processing required. This includes List of ideas for the solution of the
equations or other types of processing, problem.
such as sorting, searching, etc.)
Analyzing the Problem (PAC) (cont.)
• Example:
• Calculate the gross pay of an employee given the hours worked and the rate of the pay.
The gross pay is calculated by multiplying the hours worked by the rate of the pay.
Given Data Required Results

Processing Required Solution Alternatives


Analyzing the Problem (PAC) (cont.)
• Example:
• Calculate the gross pay of an employee given the hours worked and the rate of the pay.
The gross pay is calculated by multiplying the hours worked by the rate of the pay.
Given Data Required Results
Hours
Pay rate

Processing Required Solution Alternatives


Analyzing the Problem (PAC) (cont.)
• Example:
• Calculate the gross pay of an employee given the hours worked and the rate of the pay.
The gross pay is calculated by multiplying the hours worked by the rate of the pay.
Given Data Required Results
Hours Gross pay
Pay rate

Processing Required Solution Alternatives


Analyzing the Problem (PAC) (cont.)
• Example:
• Calculate the gross pay of an employee given the hours worked and the rate of the pay.
The gross pay is calculated by multiplying the hours worked by the rate of the pay.
Given Data Required Results
Hours Gross pay
Pay rate

Processing Required Solution Alternatives


GrossPay = Hours * PayRate
Analyzing the Problem (PAC) (cont.)
• Example:
• Calculate the gross pay of an employee given the hours worked and the rate of the pay.
The gross pay is calculated by multiplying the hours worked by the rate of the pay.
Given Data Required Results
Hours Gross pay
Pay rate

Processing Required Solution Alternatives


GrossPay = Hours * PayRate 1. Define the hours worked and pay rate
as constants.
2. Define the hours worked and pay rate
as input values.**

The ** indicates that


this is the chosen solution.
Analyzing the Problem (PAC) (cont.)
• Your turn:
• Calculate the average marks for a student based on five exams: English, Maths, History,
IT and Science.

Given Data Required Results

Processing Required Solution Alternatives


Analyzing the Problem (PAC) (cont.)
• Your turn:
• Calculate the average marks for a student based on five exams: English, Maths, History,
IT and Science.

Given Data Required Results


English marks Average marks
Maths marks
History marks
IT marks
Science marks
Processing Required Solution Alternatives
AverageMarks=(EnglishMarks + 1. Define all marks as constants.
MathsMarks + HistoryMarks + ITMarks + 2. Define all marks as user inputs. **
ScienceMarks)/5
Develop Structure Chart
• The next step in organizing the solution to a problem is to divide the processing
into subtasks called modules.
• These modules are then connected to one another to show interaction of
processing between the modules.
• The Control or Main module controls the flow to most of the other modules.
• Each module should consist of no more than 20 instructions.
• The diagram that contains all these modules is known as the interactivity chart or
structure chart.
Develop Structure Chart (cont.)
• These modules are part of
Basic structure: a set of modules that are
processed multiple times
(in a loop).

Indicates
module
reuse.

Indicates a decision:
Either Module 6 or Module 7
1100
will be executed. Not both.
Develop Structure Chart (cont.)
• Example:
• Calculate the gross pay of an employee given the hours worked and the rate of the pay.
The gross pay is calculated by multiplying the hours worked by the rate of the pay. Print
the gross pay for each employee.

Control
0000
Until NoMoreEmployees
Read module The Print module
prints the
is required to Read Calc Print
processed
enter data in the 1000 2000 3000
solution. information
The Calc module (gross pay)
processes the
data for each
employee.
Develop Structure Chart (cont.)
• Your turn:
• Calculate the average marks for a student based on five exams: English, Maths, History,
IT and Science. The student can then choose whether to display the output as the
average marks or the grade (A,B,C).

Control
0000
Until NoMoreStudents

Read Calc Print


1000 2000 3000 Indicates a decision:
Either print AverageMarks or
print Grade.

AverageMarks Grade
3100 3200
Develop IPO Chart
• The input-processing-output (IPO) chart extends information from the PAC and
interactivity/structure chart.

Input Processing Module Reference Output


Number
All input data from Processing and Take from Output data from
PAC solution interactivity or PAC
alternatives from structure chart
PAC

Each processing task


More detailed is linked with a module
reference number.
Develop IPO Chart (cont.)
• Try this:
• Calculate the gross pay of an employee given the hours worked and the rate of the pay.
The gross pay is calculated by multiplying the hours worked by the rate of the pay. Print
the gross pay for each employee.

Input Processing Module Reference Output


Number
Develop IPO Chart (cont.)

Input Processing Module Reference Output


Number
Develop IPO Chart (cont.)

Input Processing Module Reference Output


Number

Hours Worked Start 0000 Gross Pay


Pay Rate Enter Hours Worked 1000
Enter Pay Rate 1000
Calculate Pay 2000
Print Pay 3000
End 0000
Write Algorithm
• After using the structure chart and IPO chart, the programmer must develop sets
of instructions for the computer, known as algorithms.
• Each module must have separate sets of instructions.
• Modules are taken from structure chart while processing is taken from IPO chart.
• Rules:
• Instructions cannot assume anything
• Steps cannot be skipped
• Each step is executed one at a time
• All steps must be complete
Write Algorithm (cont.)
• Example:

Input Processing Module Reference Output


Number
Hours Worked Start 0000 Gross Pay
Pay Rate Enter Hours Worked 1000
Enter Pay Rate 1000
Calculate Pay 2000
Print Pay 3000
End 0000
Write Algorithm (cont.)
CONTROL MODULE (0000)
START
REPEAT
PROCESS READ
PROCESS CALC
PROCESS PRINT
UNTIL NO_MORE_EMPLOYEES
Control module uses END because
END
it is the end of processing
READ MODULE (1000)
ENTER Hours, PayRate
EXIT
Read module uses EXIT because
processing still continues
Write Algorithm (cont.)
CALC MODULE (2000)
????
EXIT

PRINT MODULE (3000)


DISPLAY ????
EXIT
Write Algorithm (cont.)
CALC MODULE (2000)
GrossPay=Hours*PayRate
EXIT

PRINT MODULE (3000)


DISPLAY GrossPay
EXIT
Draw Flowchart
• Based on the algorithm, the programmer can develop a flowchart.
• Flowchart is a graphic representation of the algorithm.
• Developing the algorithm and flowchart is the final steps in organizing a solution.
• Flowchart:
• Easy to translate into computer language
• Shows error in logic
• Identify data required for testing
Flowchart symbols
Flowchart symbols (cont.)
Flowchart example (with Modules)
Flowchart example (with Modules)
Flowchart example
• Your turn:
• Redraw the flowchart without modules.
• Algorithm:
Flowchart example
Start
• Solution:

Enter Hours

Enter PayRate

GrossPay = Hours * PayRate

Display GrossPay

End
Data Dictionary
• A data dictionary can be used to keep track of variables in a program.
• It is a list of:
• Items
• Variable name
• Data type
• Module – Where to find the variable
• Scope
• Pseudonym/Model – Alternate name of a variable in a different module
• Error checks
Data Dictionary
Item Variable Name Data Type Module Scope Pseudonym/ Error Check
Module
Hours worked Hours Numeric-real Control Local Hrs None
Hours worked Hrs Numeric-real Read/Calc Parameter Hours Hours<0
Pay rate PayRate Numeric-real Control Local Rate None
Pay rate Rate Numeric-real Read/Calc Parameter PayRate PayRate<4.00
Gross pay Pay Numeric-real Control Local None None
Gross Pay Pay Numeric-real Calc/Print Parameter None None
Documentation
• Internal Documentation
• Comments or remarks written with the instructions to explain what is being done in the
program.
• For the programmers.
• External Documentation
• Manuals or help menus written about the solution.
• For the users.
Review Learning outcomes
• List and describe the basic tools used to aid in the development of a solution to a
problem:
• Problem Analysis Chart (PAC)
• Structure Chart or Interactivity Chart
• IPO Chart
• Algorithms
• Flowcharts
• Data Dictionary
• Describe the categories of documentation
Questions?
End of topic 3

You might also like