2. Objective
1. F
2. F F F
3. F F Procedural
Object-Oriented F
4. F F
5. F F
6. F 6 F F
F F F
Mr.Warawut Chapter 1 Review 2
3. Contents
Steps in Program Development
Program Design Methodology
Procedural Object-Oriented
Objective of Structured Program Design Techniques
Introduction to Algorithm and Pseudo Code
Six Basic Computer Operations
The Three Basic Control Structures
Mr.Warawut Chapter 1 Review 3
5. Steps in Program Development
1. (Define the Problem)
2. F F (Outline the Solution)
3. (Develop and Algorithm)
4. F (Test the Algorithm for
Correctness)
5. (Programming)
6. (Testing)
7. (Document and Maintain
the Program)
Mr.Warawut Chapter 1 Review 5
6. Define the Program
Inputs
Outputs
Processing
Mr.Warawut Chapter 1 Review 6
7. Outline the Solution
F F ( )
F F F F
F
F F F (Subtask)
F F F F
F F F
F F
(Logic)
Mr.Warawut Chapter 1 Review 7
14. Program Design Methodology
Procedure-Driven
- (Processes) F (Functions)
Event-Driven
- F F F F
F F
Data-Driven
- F F F F
F F F F F F F
F F F F F F
F F F F F F
F
Mr.Warawut Chapter 1 Review 14
17. F F
Control Module
start
call module 1
call module 2
call module 3
stop
Module 1 Module 2 Module 3
begin begin begin
do 1 do x if x then y
do 2 do y else z
do 3 do z do abc
return return return
Mr.Warawut Chapter 1 Review 17
18. F
: http://www.chapterpiece.com/software-development-
process/2010/04/13/how-to-build-software-3/
Mr.Warawut Chapter 1 Review 18
22. Introduction to Algorithm and
Pseudo Code
Algorithm
F F F F F
F F F F
F F F
F F F F
Mr.Warawut Chapter 1 Review 22
23. Example Algorithm
F
1.
2. F F
3. F
4.
5. F
6.
7. 3
Mr.Warawut Chapter 1 Review 23
24. F
F
1. F F F F F F
2. F F F F F F
3. F F F F
F F
4. F
Mr.Warawut Chapter 1 Review 24
25. Example Algorithm
F
turn on calculator
clear calculator
repeat the following instructions
key in baht amount
key in decimal point (.)
key in satang amount
press addition(+) key
until all prices have been entered
write down total price
turn off calculator
Mr.Warawut Chapter 1 Review 25
26. Introduction to Algorithm and
Pseudo Code (Cont.)
Pseudo Code
F
F F
F
Mr.Warawut Chapter 1 Review 26
27. F
1. F (Statement) F F
F F
2. F
3. F F F F F (Keywords) F F
F F F F FF
F
4. F F F F
F
5. F F F F F F F
F F F F F
Mr.Warawut Chapter 1 Review 27
29. Six Basic Computer Operations
1. F F F
2. F F F
3. F F
4. F F F
5. F F
6. F F
Mr.Warawut Chapter 1 Review 29
30. F F F
F F ( ) F F F F F F
F F F F F F F F F F
F F F F F
F F F read get F F
read F F F F F
get F F F F
read studentName
get systemDate
read number1, number2
get taxCode
Mr.Warawut Chapter 1 Review 30
31. F F F
F F print, write, put, output display
print F F F F
write F F F F
put, output display F F F
print “Program Completed”
write customer record to master file
put name, address and postcode
output totalTax
display “End of data”
Mr.Warawut Chapter 1 Review 31
32. F F F (Cont.)
prompt F F F F get, F
F F F F F
promt for studentMark
get studentMark
Mr.Warawut Chapter 1 Review 32
33. F F
F F
F+ F (add)
F– F (subtract)
F* F (multiply)
F/ F (divide)
F() F /
F F F compute calculate
divide totalMarks by studentCount
salesTax costPrice * 0.10
compute C = (F – 32) * 5 / 9
Mr.Warawut Chapter 1 Review 33
34. F F F
F3
1. F initialize F set F F F
2. F F = F F
3. F store F F
initialize totalPrice to zero
set studentCount to 0
totalPrice = costPrice + salesTax
totalPrice costPrice + salesTax
store customerId in lastCustomerID
Mr.Warawut Chapter 1 Review 34
35. F
F
F if…then…else F end if
if employeeStatus is partTime then
add 1 to partTimeCount
else
add 1 to fullTimeCount
end if
Mr.Warawut Chapter 1 Review 35
36. F F
F dowhile…enddo repeat…until
dowhile file_flag <> “eof”
read student record
print studentName, address to report
add 1 to studentTotal
enddo
eof – End Of File
Mr.Warawut Chapter 1 Review 36
38. The Three Basic Control Structures
Sequence
Selection
Repetition
Mr.Warawut Chapter 1 Review 38
39. Sequence Format
statement a
statement b
statement c
:
:
Mr.Warawut Chapter 1 Review 39
40. Example: Sequence
add 1 to pageCount
print heading line1
print heading line2
set lineCount to zero
read customer record
Mr.Warawut Chapter 1 Review 40
41. Selection Format
if condition p is true then
statement(s) in true case
else
statement(s) in false case
end if
Mr.Warawut Chapter 1 Review 41
42. Example: Simple IF Statement
if accountBalance < 300000 then
serviceCharge = 5.00
else
serviceCharge = 2.00
end if
Mr.Warawut Chapter 1 Review 42
43. Example: Null False Branch
if employeeStatus = partTime then
add 1 to partTimeCount
end if
Mr.Warawut Chapter 1 Review 43
44. Example: Combined IF Statement 1
if employeeStatus = partTime
and employeeGender = female then
add 1 to partTimeCount
end if
Mr.Warawut Chapter 1 Review 44
45. Example: Combined IF Statement 2
if (recordCode = “23” or updateCode = delete)
and accountBalance = zero then
delete customer record
end if
Mr.Warawut Chapter 1 Review 45
46. Example: Combined IF Statement 3
if not (recordCode = “23”
and updateCode = delete) then
update customer record
end if
Mr.Warawut Chapter 1 Review 46
47. Example: Nested IF Statement 1
if recordCode = “A” then
increment counter_A
else
if recordCode = “B” then
increment counter_B
else
if recordCode = “C” then
increment counter_C
else
increment errorCounter
end if
end if
end if
Mr.Warawut Chapter 1 Review 47
48. Example: Nested IF Statement 2
if employeeStatus = partTime then
if employeeGender = female then
if employeeAge > 30 then
add 1 to matureFemaleEmployee
else
add 1 to youngFemaleEmployee
end if
else
add 1 to maleEmployee
end if
else
add 1 to fullTimeEmployee
end if
Mr.Warawut Chapter 1 Review 48
49. Repetition Format
dowhile
dowhile condition p is true
statement block
enddo
Mr.Warawut Chapter 1 Review 49
50. Repetition Format (Cont.)
repeat…until
repeat
statement
statement
:
:
until condition is true
Mr.Warawut Chapter 1 Review 50
51. Example: dowhile loop 1
set studentTotal to zero
dowhile studentTatal < 50
read student record
print studentName, address to report
add 1 to studentTotal
enddo
Mr.Warawut Chapter 1 Review 51
52. Example: dowhile loop 2
Process Student_record
set studentCount to zero
read student record
dowhile studentNumber not equal 999
write student record
increment studentCount
read student record
enddo
print studentCount
end
Mr.Warawut Chapter 1 Review 52
53. Example: repeat…until loop
Process Student_record
set studentCount to zero
repeat
read student record
if studentNumber not equal 999
write student record
increment studentCount
end if
until studentNumber = 99
print studentCount
end
Mr.Warawut Chapter 1 Review 53