Você está na página 1de 23

Faculty of Computer Science and Information Technology

BIC 10204 Algorithm and Programming

Problem Solving and


Algorithm

1
Problem Solving and
Chap 2
Algorithm

Withdraw money from ATM machine


Register subjects through online
system
Buy cold drinks from vending machine
Calculate the monthly salary payment
Calculate car loan interest
Determine odd and even numbers
Count the total visitor of a Web
Determine air velocity in physic lab
2
Problem Solving and
Chap 2
Algorithm

3
Problem Solving and
Chap 2
Algorithm

Writing computer program

4
Problem Solving and
Chap 2
Algorithm
Procedure or formula
for solving problem

Sequence set of
steps taken to solve
a problem
Instructions for actions to be executed by computer

(input/process/output)
5
Problem Solving and
Chap 2
Algorithm

6
Problem Solving and
Chap 2
Algorithm

Simple codes which resembles


program code that will be written
during implementation phase
(program coding)

A text-based design tool that helps


programmmers to develop algorithm

Using natural language


Compact and informal high level (communication language
language description of a computer e.g: Malay/English) wording
programming algorithm phrase

7
Problem Solving and
Chap 2
Algorithm
Keywor
d?
print
if student's grade is greater than or equal to 60 means
print the statement "passed" display on
else the screen
print the statement "failed" monitor

if credit card number is valid


execute transaction based on number and order
else
show a generic failure message show also
means
display on the
8
screen monitor
Problem Solving and
Chap 2
Algorithm

Keywor
d?
set
Set total to zero means
Set grade counter to one assign the
While grade counter is less than or equal to ten value,e.g:
Input the next grade
Add the grade into the total total = 0
Set the class average to the total divided by ten
Print the class average.

while is used
whenever the
process is to 9
be continued
Problem Solving and
Chap 2
Algorithm

Write the pseudo code based on the IPO (input/process/


output) which you have identified during the analyzing
phase
Identify the keyword(s) based on the IPO

Did you remember the steps weve done in Chap 1 ?


10
Problem Solving and
Chap 2
Algorithm

Identify the problem

Input Value of x and a

Process Replace the value of x and a in the


formula, y = 2x +a -6
Output The value of the equation, y

11
Problem Solving and
Chap 2
Algorithm
(Using example from chapter 1)
Write a
Given the value of x is 10 and a is 12, program!
find the result of the following equation:
y = 2x + a - 6 Keywor
d

start
read the value of x
read the value of a
compute the value of y as y = 2x + a -6
display/print the result (or the value of y) 12
end
Problem Solving and
Chap 2
Algorithm
(Using example from chapter 1)
Uncle Degawan wants to buy 5 tins of paint from
Cindas shop. The price of each tin of the paint is
RM 15.60. Calculate the price which Uncle Degawan
have to pay for all the tin of paints he bought.
Write a
program!
start
read the amount of paint
compute the total price as price per tin times by amount of
paint
display/print the result (or the total price) Keywor
end d?13
Problem Solving and
Chap 2
Algorithm

(Using example from chapter 1)


Mrs Sue needs to determine her students grade for
programming subject based on the mark scored during
final examination. The A grade will be given if the mark
scored is between 85 to 100. If a student has scored 90
marks, what is the grade that Mrs Sue should give to the
student?

Write a program!

14
Problem Solving and
Chap 2
Algorithm

Keywor
d
start
read the student mark
if mark is greater than 85 and mark is less than 100, then
set grade as A
display/print the grade
end
Keywor
d

15
Problem Solving and
Chap 2
Algorithm

Schematic representation of an
algorithm or process

Helps to visualize the


content/steps better or to find
flaws in process
Illustrate the steps in the
process

16
Problem Solving and
Chap 2
Algorithm

Start/Stop
The terminator symbol marks the
starting or ending point of the
system. It usually contains the
word "Start" or "End."

Action or Process
A box can represent a single step
("add two cups of flour"), or and
entire sub-process ("make
bread") within a larger process.
17
Problem Solving and
Chap 2
Algorithm

Decision
A decision or branching point. Lines
representing different decisions
emerge from different points of the
diamond.
Input/Output
Represents material or information
entering or leaving the system,
such as customer order (input) or a
product (output).

18
Problem Solving and
Chap 2
Algorithm

Flow Line
Lines indicate the sequence of
steps and the direction of flow.

Connector
Indicates that the flow continues
where a matching symbol
(containing the same letter) has
been placed.
19
Problem Solving and
Chap 2
Algorithm

Off Page
Indicates that the process continues off
page.

Database
Indicates a list of information with a
standard structure that allows for
searching and sorting.

20
Problem Solving and
Chap 2
Algorithm

21
Problem Solving and
Chap 2
Algorithm

What software use to


draw flowchart?

You can use Ms Word >


AutoShapes> Flowchart or
other flowchart drawing tools
e.g: SmartDraw/Visio Drawing, etc.

22
Problem Solving and
Chap 2
Algorithm

(Based on the Example 1 (Slide number 23))


Start
start
read the value of x
Read x
read the value of a
compute the value of y as y = 2x + a -6
display/print the result (or the value of y)
Read a end

y = 2x + a - 6

Print y

23
End

Você também pode gostar