1
Program Development
Problem definition Problem analysis Algorithm design Program coding Program testing Program documentation
3
Problem Definition
?The computer accepts a date of the year 1994 and outputs the date n days after the input date.
Here is our problem.
5
Problem Analysis
?The computer accepts a date of the year 1994 and outputs the date n days after the input date.
How to solve the problem?
6
Problem Analysis - Input
?The computer accepts a date of the year 1994 and outputs the date n days after the input date.
A starting Date The number of days that f
ollows
First, identify the input.
7
Problem Analysis
?The computer accepts a date of the year 1994 and outputs the date n days after the input date.
The output is next, right?
8
Problem Analysis - Output
?The computer accepts a date of the year 1994 and outputs the date n days after the input date.
Very Good!
The date n days after the input date
9
Problem Analysis
?The computer accepts a date of the year 1994 and outputs the date n days after the input date.
What about the algorithm?
10
Problem Analysis
?The computer accepts a date of the year 1994 and outputs the date n days after the input date.
IIe got a solution!
13
Structure Chart - Level 1
Look_Up_Date
Break the problem down into subproblems
Initialization Get_Input Calculate_Date Output_Date
14
Structure Chart - Level 2
Look_Up_Date
Calculate_DateGet_Input Initialization Output_Date
Input Starting Input Number . Date of days
Further break down if necesary
15
Structure Chart Completed
Done!
Look_Up_Date
Input Starting Date
Calculate_DateGet_Input Initialization
Input Number of Days
Output_Date
18
Step-wise Refinement
2.1 Input Starting Date
2.2. Input Number of Days
1. Initialization 2. Get_Input
3. Calculate_Date 4. Output_Date
program Look_Up_Date;
{ variable declarations }
:
{ procedure declarations }
:
:
begin
Initialization;
Get_Input;
Calculate_Date;
Output_Date
end.
program Look_Up_Date;
{ variable declarations }
var Year, Month, Day : integer;
{ procedure declarations }
:
:
begin
Initialization;
Get_Input ( Year, Month, Day );
Calculate_Date ( Year, Month, Day );
Output_Date ( Year, Month, Day )
end.
23
Test Cases
Choose suitable test cases Beware of Boundary Conditions For Example, to test a program which decides
whether an input number is greater than or equal to 100.
Three test cases should be used. Do you know which three ?
24
Test cases (Continue...)
(1) any numbers small than 100 e.g. 50 (2) the number 100 (3) any numbers greater than 100 e.g. 200