Post on 14-Nov-2014
description
Universiti Tun Hussien Onn MalaysiaFaculty of Mechanical and Manufacturing Engineering
• 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
1. Go to the ATM machine.2. Insert ATM card.3. Select language.4. Enter pin number.5. Select withdrawal option from menu.6. Enter amount of money to withdraw.7. Take the money.8. Take the bank slip.
Example 2: Money withdrawal algorithm
A text-based design tool that helps programmers to develop algorithm
Using natural language
(communication language e.g: Malay/English)
wording phrase
Compact and informal high level language description of a computer
programming algorithm
Simple codes which resembles program code that will be written during implementation phase (program coding)
1. Consist of a statement of instructions in sequence2. Every step consists of keyword3. Every step should be written in different step, if continued,
thru next row must be indented4. if/else for condition, while/do for repetition5. Every step must contain clear statement and easy to understand6. Use start for beginning of operation, and end/halt for finishing it.
Computing Sales Tax : Pseudo-code the task of computing the final price of an item after figuring in sales tax. Note the three types of instructions:
Input (get or read), process/calculate (=) and output (display)
1. Start2. get price of item3. get sales tax rate4. sales tax = price of item * sales tax rate5. Final price = price of item + sales tax6. display final price7. 7 halt/end
if student's grade is greater than or equal to 60 print the statement "passed"
else print the statement "failed"
Keyword
?
print means
display on the screen
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 screen
monitor
Set total to zero Set grade_counter to one While grade_counter is less than or equal to ten
Input the next gradeAdd the grade into the total
Set the class_average to the total divided by ten Print the class_average.
Keyword?
set meansassign
the value,e.g
:total = 0
while is used
whenever the
process is to be
continued
Write the pseudo code based on the IPO (input/process/
output) which you have identified during the analyzing phaseIdentify the keyword(s) based on the IPO
Input Value of x and a
Process Replace the value of x and a in theformula, y = 2x +a -6
Output The value of the equation, y
Identify the problem
Given the value of x is 10 and a is 12, find the result of the following equation:
y = 2x + a - 6
startread the value of xread the value of acompute the value of y as y = 2x + a -6display/print the result (or the value of y)end
Write a program!
Keyword
Uncle Degawan wants to buy 5 tins of paint from Cinda’s shop. The price of each tin of the paint is RM 15.60. Calculate the price which Uncle Degawanhave to pay for all the tin of paints he bought.
startread the amount_of_paintcompute the total_price as price_per_tin times by amount_of _paintdisplay/print the result (or the total_price)end
Write a program!
Keyword?
startread the student markif mark is greater than 85 and mark is less than 100, then set grade as Adisplay/print the gradeend
Keyword
Keyword
Keyword
startSet total to zeroSet grade counter to one
While grade counter is less than or equal to teninput the next gradeadd the grade into the totaladd one to the grade counter
Set the class average to the total divided by tenPrint the class averageend
Keyword
Keyword
Keyword
Schematic representation of an algorithm or process
Helps to visualize the content/steps better or to find flaws in processIllustrate the steps in the process
Use symbols to represent the
steps
Start/Stop (oval)The terminator symbol marks the starting or ending point of the system. It usually contains the word "Start" or "End."
Action or Process (rectangle)A box can represent a single step ("add two cups of flour"), or and entire sub-process ("make bread") within a larger process.
Decision (Diamond)A decision or branching point. Lines representing different decisions emerge from different points of the diamond.
Input/Output (Parallelogram)Represents material or information entering or leaving the system, such as customer order (input) or a product (output).
Flow LinesLines indicate the sequence of steps and the direction of flow.
On-Page ConnectorIndicates that the flow continues where a matching symbol (containing the same letter) has been placed in the same page.
Off-Page ConnectorIndicates that the process continues on another page.
Database / Disk Storage Input-Output SymbolIndicates input from or output to disk storage.
What software use to draw flowchart?
You can use Ms Word > AutoShapes> Flowchart or
other flowchart drawing tools e.g: SmartDraw/Visio Drawing,
Rational Rose,etc.
1. Sequence Structure a series of steps or statements that are executed in order.
begin
Statement_1
Statement_2
…
Statement_n
end
Statement 1
Statement 2
Statement..n
Read x
Read a
y = 2x + a - 6
Display y
Start
End
2. Selection Structure Define two courses of action depending on the outcome condition ( true or false)
How to go to BP Mall ?1. Begin2. Do you have a car ?3. If yes, drive your car towards BP Mall4. Or else go by bus5. Reach BP Mall 6. End
3. Repetition Control Structures Specifies a block of one or more statements that are repeatedly executed until a condition is satisfied.
while condition
loop-body
end_while
condition Loop_bodyYes
startSet total to zeroSet grade_counter to one
While grade_counter is less than or equal to teninput the next gradeadd the grade into the totaladd one to the grade_counter
Set the class average to the total divided by tenPrint the class averageend
startread the amount_of_paintcompute the total_price as price_per_tin times by amount_of paintdisplay/print the result (or the total price)end
startread the student markif mark is greater than 85 and mark is less than 100, then set grade as Adisplay/print the gradeend
Convert to
flowchar
Convert to
flowchart
A box has height, width and length. Write the pseudo code to calculate the volume of a box.
Write the pseudo code to calculate salary of an employee for a month.
Convert to
Convert to
flowchart