Vous êtes sur la page 1sur 27

# Computer and Information Technology for (HKCEE) Module A2

## 1.1 Solving a Problem in a Systematic Way

1.2 Problem Definition
1.3 Problem Analysis
1.4 Algorithm Design
1.5 Program Coding
1.6 Program Testing
1.7 Program Documentation
Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.1 Solving a Problem in a

Systematic Way
1. Problem definition
2. Problem analysis
program
3. Algorithm design
development
4. Program coding life cycle
5. Program testing and debugging
6. Program documentation

## © Longman Hong Kong Education Page2

Computer and Information
Technology for (HKCEE)
Module A2: Part A

Problem Definition

Problem Analysis

Algorithm Design

Program Coding

Program Testing
and Debugging
Normal flow
Iteration flow Program
Documentation

## © Longman Hong Kong Education Page3

Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.2 Problem definition

Get a well-defined problem statement
Study the problem statement
Specify the clear requirements for the problem

## © Longman Hong Kong Education Page4

Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.3 Problem Analysis

Three components of a problem:
Input
Processing
Output

## © Longman Hong Kong Education Page5

Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.3 Problem Analysis

IPO chart (defining diagram)
present the three components of a problem

## © Longman Hong Kong Education Page6

Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.3 Problem Analysis

Top-down approach
The problem is divided into more easily handled
subprograms.
Solutions of the subprograms create a solution to
the overall problem.

## © Longman Hong Kong Education Page7

Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.4 Algorithm Design

Algorithm
a logical sequence of steps
clearly specify how to perform a task in a finite
number of steps to lead to the solution

## © Longman Hong Kong Education Page8

Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.4 Algorithm Design

Flowchart visually presents
the flow of data through a processing system
the operations performed within the system
the sequence in which they performed

## © Longman Hong Kong Education Page9

Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.4 Algorithm Design

flowchart symbols

## © Longman Hong Kong Education Page10

Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.4 Algorithm Design

Sequence Control Structure
sequential flow of steps

## © Longman Hong Kong Education Page11

Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.4 Algorithm Design

Selection Control Structure
one or more alternate flows of steps of a
conditional branch
If-Then-Else structure
False True
Condition

Process 1 Process 2

## © Longman Hong Kong Education Page12

Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.4 Algorithm Design

Selection Control Structure

If-Then structure
True
Condition

False Process

## © Longman Hong Kong Education Page13

Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.4 Algorithm Design

Selection Control Structure
Case structure
Condition

## Case 1 Case 2 Case N

Process 1 Process 2 ... Process N

## © Longman Hong Kong Education Page14

Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.4 Algorithm Design

Iteration Control Structure
repetitive execution of a block of steps
Protest loop:
While-Do loop
False
Condition
True
Process

## © Longman Hong Kong Education Page15

Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.4 Algorithm Design

Iteration Control Structure
Posttest loop:
Repeat-Until loop

Process

False
Condition
True
© Longman Hong Kong Education Page16
Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.4 Algorithm Design

Pseudocode
an English-like statement that presents the logic
of the algorithm
Common words
Divide by giving, Set, Store, Get, Input, Print, Write,
Display, Compute
Arithmetic Operators
+, –, *, /

## © Longman Hong Kong Education Page17

Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.4 Algorithm Design

Pseudocode
Symbols
(), ←
Relational Operators
=, <, <=, >, >=
Logical Operators
AND, OR, NOT
Keywords
BEGIN-END, IF-THEN-ELSE-ENDIF, IF-THEN-ENDIF,
CASE-OF-ENDCASE, DOWHILE-ENDDO,
REPEAT-UNTIL
© Longman Hong Kong Education Page18
Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.4 Algorithm Design

Solution algorithm
a complete set of detailed steps that describe how
a problem to be solved
Graphical descriptions of procedures using flowcharts
Written descriptions of procedures using pseudocodes

## © Longman Hong Kong Education Page19

Computer and Information
Technology for (HKCEE)
Module A2: Part A

program
coding
computer
solution
programming
algorithm
language

## © Longman Hong Kong Education Page20

Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.6 Program Testing and Debugging

Three types of errors:
syntax errors
logic errors
run-time errors
Debugging process
test a syntax-error
a source compiler a syntax-error data
free & logic-error
code free program
free program

## © Longman Hong Kong Education Page21

Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.6 Program Testing and Debugging

Syntax rules
govern the structure of the program instructions
Common syntax errors
typing mistakes
data types mismatch
undefined identifiers
unknown identifiers
incorrect punctuations or symbols
missing punctuations or symbols
missing reserved words
© Longman Hong Kong Education Page22
Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.6 Program Testing and Debugging

Logic errors are caused by
incorrect design of algorithm
incorrect program coding from the solution
algorithm
Dry run
use test data (normal and abnormal) to check a
program for logic errors

## © Longman Hong Kong Education Page23

Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.6 Program Testing and Debugging

Run-time errors
errors encountered during program execution
Common run-time errors
infinite loop
infinite result
data overflow
illegal operation

## © Longman Hong Kong Education Page24

Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.7 Program Documentation

Program documentation
vital for the development, operation and future
maintenance of the program
help programmers understand the program logic
variables
input and output files
reports
input and enquiry screens
brief description for each subprograms

## © Longman Hong Kong Education Page25

Computer and Information
Technology for (HKCEE)
Module A2: Part A

## 1.7 Program Documentation

External documentation
reference manual
user manual

## © Longman Hong Kong Education Page26

Computer and Information Technology for (HKCEE) Module A2

END