1.0 Approach In Problem Solving

1.1 Steps in problem Solving

Problem Solving process

• Programmers use a problem-solving process to

create a computer program.

• Steps in problem-solving process:

1. Problem Analysis

2. Design a solution

3. Implementation

4. Testing

5. Documentation

Problem Solving process

1. Problem Analysis

Define a problem and plan a solution to solve the

problem.

Identify the problem’s output and input.

Output - the goal of solving the problem

Input – items needed to achieve the goal

Programmers use IPO chart to organize and summarize

the results of the problem analysis step.

I - Input

P - Processing

O - Output

Problem Solving process

2. Design Solution

• Develop logical sequence of steps to solve the

problem.

• Plan algorithm that will transform the problem’s input

into its output.

• 2 types of algorithm :

1. Pseudo code – logical sequence of steps to solve the

problem in simple English statement

2. Flowchart - logical sequence of steps to solve the

problem by using graphic

representation/ symbol.

Problem Solving process

• 3. Implementation

• Translate the algorithm into coding and type the

programming language code into the computer

• The process of translating the algorithm into a

language that the computer can execute.

• Example: Java programming language

Problem Solving process

4. Testing

• Trace and check the code with algorithm to make

sure that each instruction in the algorithm was

translated correctly.

• Evaluate the program by entering the coding into

the computer and then execute the program.

• The program must runs without error (bugs) and

produces the expected output before it is release to

the user.

Problem Solving process

• 5. Documentation

• Documentation is a written detailed description

of the programming cycle and specific facts

about the program.

• Typical program documentation materials

include:

o the origin and nature of the problem

o a brief narrative description of the program

o logic tools such as flowcharts and

pseudo code

o data-record descriptions

o program listing

o testing results

Problem Solving process

• Tools to analyze problems and

develop algorithms.

IPO analysis

Pseudo code

Flowcharts

1. Problem Analysis

WHAT is the purpose of analyzing a problem?

1.To determine the goal of solving the problem

which is known as output.

• Output should answer the following question:

What does the user want to find, to print

on paper or to display on the screen?

** Answer (output) must be stated as nouns

and adjectives.

Problem Analysis

2. To determine the information needs to achieve

the goal which is known as input.

• Input should answer the following question:

What information is needed to

calculate, print or display on the

screen?

** Answer (input) must be stated as nouns and

adjectives. An example of input:

Input : width, height

Problem Analysis

3.To determine the processing item.

A formula or process to transfer

the input into the output.

** Answer (process) must be stated as verbs.

An example of process:

Process : calculate the area of rectangle

(formula area = width x height)

Problem Analysis

FUNCTIONS of IPO analysis :

To organize and summarize the results of a

problem analysis.

To show the Input, Process and Output of the

problem.

Problem Analysis

IPO Analysis:

Identify

Input :

Process :

Output :

• Read the problem statement given and identify :

1. Input (what is the data needed?)

2. Process (How to process data,

what formula to use?)

3. Output (What to produce?)

Problem Analysis

Exercise 1:

Problem statement:

Calculate the area of a rectangle.

width

height

Problem Analysis

Analyze the problem:

• What is a rectangle?

A shape with width and height

• What to find? (output)

Area

• What is the formula for area? (process)

Area = width * height

• What is needed to calculate area? (input)

width and height

Problem Analysis

Write IPO Analysis:

• Input : width, height

• Process : calculate the area of rectangle

• Output : area of rectangle

Note: calculation or formula is not shown in Process

Problem Analysis

Exercise 2:

Problem statement:

Determine the total cost of apples, given the

number of kilos of apples purchased and the cost of

apples per kilo.

Problem Analysis

Analyze the problem:

• What to find?

Total cost

• How to find it? :

Total cost = number of kilos of apples

purchased * cost

of apples per kilo

• What is needed?

cost of apples per kilo,

number of kilos of apples purchased

Problem Analysis

Write IPO Analysis:

• Input : Cost of apples per kilo,

number of kilos of apples purchased.

• Process : Calculate the Total cost

• Output : Total cost

Note: calculation or formula is not shown in Process

Problem Analysis

Exercise 3:

Problem statement:

Create an IPO chart for the following problem.

Calculate the salary of an employee who works

by hourly basis. The formula to be used is Salary =

Hour works * Pay rate

Problem Analysis

Analyze the problem:

• What to find?

Salary

• How to find it?

Salary = Hour Work* Pay Rate

• What is needed?

Hour Work

Pay Rate

Problem Analysis

Write IPO Analysis:

• Input : Hour Work, Pay rate

• Process : Calculate Salary

• Output : Salary

Note: calculation or formula is not shown in Process

Problem Analysis

Exercise 4:

Problem statement:

Write a program to convert Fahrenheit

temperatures into Celsius temperatures

Problem Analysis

Analyze the problem:

• What to find?

Celsius temperature (output)

• How to find it?

Convert Fahrenheit temperature into Celsius

temperature

• What is needed?

Fahrenheit temperature (input)

Problem Analysis

Write IPO Analysis:

• Input : Fahrenheit temperature

• Process : calculate to convert Fahrenheit temperature

into Celcius temperature

• Output : Celcius temperature

Note: calculation or formula is not shown in Process

Steps in Problem Solving

The End