Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Program Flowchart,
Pseudocode & Algorithm
development
Week 2:
Wednesday 1/22/2003
Friday
Abdou Illia, Spring 2003
1/24/2003
Project 1
Exercise # 8, page 57
Bohl & Rynns textbook
Learning Objectives
Draw flowcharts
Write pseudocodes
Example
Pseudocode:
English-language
statements that describe
the processing steps of a
program in paragraph
form.
START
READ EMPLOYEE DATA
COMPUTE GROSS PAY
COMPUTE DEDUCTIONS
COMPUTE NET PAY
WRITE EMPLOYEE PAYCHECK
STOP
Algorithm ?
A System Flowchart
A Program Flowchart
A Pseudocode, etc.
Algorithm vocabulary
SYMBOLS
START
NAME
USE
Terminal interrupt
symbols
STOP
Input/Output symbol
Process symbol
Algorithm vocabulary
SYMBOLS
NAME
USE
Flowline symbol
Decision symbol
Predefined-process
symbol
Decision-making operations
Algorithm vocabulary
SYMBOLS
NAME
USE
Connector symbol
Preparation symbol
10
Algorithm vocabulary
Item
Meaning
Variables
Data
independence
Assignment
statement
Constant
Example
READ
REGSALES,
SALESALES
Comment
1) Variables names are placeholders for values
2) Variable names are chosen
by programmer
3) Names should be descriptive
READ
$1000,
$3000
REGCOM =
REGSALES
*.06
.06
General form
:
READ
AMOUNT
NO
Is
Condition
True ?
NO
YES
Could be many
processings,
AMOUNT
DISCOUNT =
AMOUNT * .10
SUBBIL=
AMOUNT
SUBBIL =
AMOUNT
DISCOUNT
Processing 2
:
:
YES
> 200 ?
Processing 1
Processing 3
11
Could be many
processings,
:
:
12
13
14
Project 1
15
16
Exercise 11 (Chapter 2)
Look at the program flowchart on the next slide, and answer the following questions:
(a)
(b)
(c)
(d)
Simulate the execution of this algorithm, assuming the values shown below are
read as input for the first four variables named.
NAME
Mrs. A. B. Wallace
ITEM
Blouse
QTY
PRICE
49.99
AMTOD
DISCOUNT
SUBBILL
TAXES
BILL
DISCOUNT =
AMTOD * .10
SUBBILL =
AMTOD - DISCOUNT
TAXES =
SUBBILL * .05
BILL =
SUBBILL + TAXES
WRITE NAME,
ITEM, BILL
STOP
17
18
START
READ
NAME, SSN,
CREDITS
NO
CREDITS
10 ?
TUITION =
TUITION = 1000
TUITION = 1000
100 * CREDITS
ELSE
TUITION = 100 * CREDITS
WRITE
NAME, SSN, TUITION
ENDIF
Write NAME, SSN, TUITION
Stop
STOP
19
Pseudocode
TUITION = 1000
ELSE
TUITION = 100 * CREDITS
Stop
20
Pseudocode
TUITION = 1000
ELSE
TUITION = 100 * CREDITS
ENDIF
Write NAME, SSN, TUITION
Stop
21
Exercise 19 (Chapter 4)
22
WEEKLY
PAYROLL
PROGRAM
NAME, NUM,
PAY
23
24
25
Summary Questions
1. Distinguish between Algorithm on the one
hand, and Program flowchart and Pseudocode
on the other hand. Discuss the relations
between the two.
2. (a) List the main keywords used in
Pseudocodes. (b) What control structures they
represent.
You should know how to design program logic
using Program Flowcharts & Pseudocodes
(Review Exercises 1,2,3 above & Exercise 15
Ch.4 and answer on page 339)
26