PROBLEM SOLVING AND PROGRAM DESIGN
5 Steps in Problem Solving
Step 1 Define the problem (Problem Definition)
Step 2 Propose and Evaluate Solutions
Step 3 Determine and Outline the solution (IPO Chart)
Step 4 Develop the algorithm (Algorithm) / Flow Chart
Step 5 Test and validate the algorithm (Trace Table)
9 Steps in Programming
Step 1 Define the problem (Problem Definition)
Step 2 Propose and Evaluate Solutions
Step 3 Determine and Outline the solution (IPO Chart)
Step 4 Develop the algorithm (Algorithm) / Flow Chart
Step 5 Test and validate the algorithm (Trace Table)
PROGRAM IMPLEMENTATION
Step 6 Code the algorithm into Program (Code program / Create source code)
Step 7 Compile or Interpret or Link program
Step 8 Execute or Run the program (Run on Compiler or Interpreter)
Step 9 Document and maintain the program (add comments, make changes)
Applying Steps 1 to 9 to problem below
(1) Write an algorithm and program to enter the current year, an individual’s year
of birth and it calculates and prints, the age of the individual.
Step 1 Define the problem (Problem Definition)
Write an algorithm and program to read the current year, an individual’s year of birth
and it calculates and prints, the age of the individual.
Step 2 Propose all possible solutions.
1
Step 3 Outline the solution (IPO Chart)
IPO Chart
INPUT PROCESS OUTPUT
CurrentYear Read CurrentYear Age
BirthYear Read Birth Year
Age = CurrentYear -
BirthYear
Print Age
Step 4 Develop the algorithm (Algorithm) / Flow Chart
AgeCalculator
VARIABLES
CurrentYear As Int
BirthYear As Int
Age As Double
BEGIN
PRINT “What is the current year”
READ CurrentYear
PRINT “What is your year of birth”
READ BirthYear
Age = CurrentYear – BirthYear
PRINT “Your age is” Age
END
FLOW CHART
Flow Chart Symbols
INPUT / OUTPUT 2 DECISION
BEGIN
END PROCESS
CONNECTOR
FLOW
Step 5 Test the algorithm (Trace Table)
CODE
Step 6 Code the algorithm (Code program)
Step 7 Compile or Interpret or Link program
This happens automatically in most cases by the program compiler / interpreter.
Step 8 Run the program (Run on Compiler or Interpreter)
Step 9 Document and maintain the program (add comments, make changes)