IF Statements flowcharts and pseudocode - PowerPoint PPT Presentation

About This Presentation
Title:

IF Statements flowcharts and pseudocode

Description:

IF Statements flowcharts and pseudocode Please open the speaker notes - they contain additional information! IF Statements flowcharts and pseudocode Please open the ... – PowerPoint PPT presentation

Number of Views:251
Avg rating:3.0/5.0
Slides: 21
Provided by: Pris76
Category:

less

Transcript and Presenter's Notes

Title: IF Statements flowcharts and pseudocode


1
IF Statements flowcharts and pseudocode
  • Please open the speaker notes - they contain
    additional information!

2
Simple IF - processing on Y only
IF AMT gt 5000
Y
N
AMT x 10 ANS
if amt gt 5000 ans amt 10 end if
3
Simple IF - processing on Y or N
IF AMT gt 5000
Y
N
ANS AMT x 5
ANS AMT x 10
In this example, if the AMT is greater than 5000
then we want to multiply AMT by 10 and store the
answer in ANS. If the AMT is not greater than
5000 then we want to multiply AMT by 5 and store
the answer in ANS.
if amt gt 5000 ans amt 10 else ans
amt 5 end if
4
IF INVCD A
AND relationship
Y
N
IF AMT gt 5000
Y
N
MOVE OKAY TO MSG
if invcd A if amt gt 5000 move OKAY
to msg end if end if
Both statements must be true for the msg to
receive the word OKAY. If either statement is
false, no processing is done.
5
IF INVCD A
AND relationship
Y
N
IF AMT gt 5000
Y
N
MOVE OKAY TO MSG
if invcd A if amt gt 5000 move OKAY
to msg end if end if
if invcd A and amt gt 5000 move OKAY t0
msg end if
6
IF INVCD A
AND relationship
Y
N
IF AMT gt 5000
Y
N
MOVE PROBLEM TO MSG
MOVE PROBLEM TO MSG
MOVE OKAY TO MSG
if invcd A if amt gt 5000 move OKAY
to msg else move PROBLEM to msg
end if else move PROBLEM to msg end if
if invcd A and amt gt 5000 move OKAY to
msg else move PROBLEM to msg end if
7
IF INVCD A
AND relationship
Y
N
IF AMT gt 5000
Y
N
MOVE PROBLEM TO MSG
MOVE OKAY TO MSG
if invcd A if amt gt 5000 move OKAY
to msg else move PROBLEM to msg
end if end if
8
IF INVCD A
AND relationship
Y
N
IF AMT gt 5000
Y
N
MOVE BAD CODE TO MSG
MOVE PROBLEM TO MSG
MOVE OKAY TO MSG
if invcd A if amt gt 5000 move OKAY
to msg else move PROBLEM to msg
end if else move BAD CODE to msg end if
9
IF INVCD A
OR relationship
N
Y
MOVE OKAY TO MSG
IF AMT gt 5000
Y
N
MOVE OKAY TO MSG
if invcd A move OKAY to msg else if
amt gt 5000 move OKAY to msg end
if end if
One or the other of the if questions must be true
for OKAY to be moved to msg.
10
IF INVCD A
OR relationship
N
Y
MOVE OKAY TO MSG
IF AMT gt 5000
Y
N
MOVE OKAY TO MSG
if invcd A move OKAY to msg else if
amt gt 5000 move OKAY to msg end
if end if
if invcd A or amt gt 5000 move OKAY to
msg end if
11
IF INVCD A
OR relationship
N
Y
MOVE OKAY TO MSG
IF AMT gt 5000
Y
N
MOVE PROBLEM TO MSG
MOVE OKAY TO MSG
if invcd A move OKAY to msg else if
amt gt 5000 move OKAY to msg else
move PROBLEM to msg end if end if
12
IF INVCD A
OR relationship
N
Y
MOVE OKAY TO MSG
IF AMT gt 5000
Y
N
MOVE PROBLEM TO MSG
MOVE OKAY TO MSG
if invcd A move OKAY to msg else if
amt gt 5000 move OKAY to msg else
move PROBLEM to msg end if end if
if invcd A or amt gt 5000 move OKAY to
msg else move PROBLEM to msg end if
13
IF INVCD A
OR relationship
N
Y
MOVE CODE - OKAY TO MSG
IF AMT gt 5000
Y
N
MOVE PROBLEM TO MSG
MOVE AMT - OKAY TO MSG
if invcd A move CODE - OKAY to msg else
if amt gt 5000 move AMT - OKAY to msg
else move PROBLEM to msg end if end
if
14
cond1 AND (cond 2 OR cond3)
if invcd A if amtfst gt 500 move
OKAY to msg else if amtsnd gt 200
move OKAY to msg end if end if end
if
IF INVCD A
Y
N
IF AMTFST gt 500
Y
N
MOVE OKAY TO MSG
IF AMTSND gt 200
Y
N
MOVE OKAY TO MSG
15
cond1 AND (cond 2 OR cond3)
if invcd A and (amtfst gt 500 or amtsnd gt
200) move OKAY to msg end if
IF INVCD A
Note the use of parenthesis here. In boolean
logic AND gets resolved before OR. That means if
we did not have the parenthesis, it would treat
this like invcd A and amtfst gt 500 or just
amtsnd gt 200.
Y
N
IF AMTFST gt 500
Y
N
Continue below
MOVE OKAY TO MSG
IF AMTSND gt 200
Y
N
We want the logic to be invcd A and either
amtfst gt 500 or amtsnd gt200. To do this, we need
to change the order of operation so that the two
things in the or relationship are grouped
together. We do this by using parenthesis.
MOVE OKAY TO MSG
16
if invcd A if amtfst gt 500 or amtsnd gt
200 move OKAY to msg end if end if
cond1 AND (cond 2 OR cond3)
IF INVCD A
Y
N
IF AMTFST gt 500
Y
N
MOVE OKAY TO MSG
IF AMTSND gt 200
Y
N
MOVE OKAY TO MSG
17
cond1 AND cond 2 OR cond3
if invcd A and amtfst gt500 or amtsnd gt 200
move OKAY to msg end if
IF INVCD A
Y
N
IF AMTSND gt 200
Y
N
IF AMTFST gt 500
Y
N
MOVE OKAY TO MSG
MOVE OKAY TO MSG
IF AMTSND gt 200
Y
N
MOVE OKAY TO MSG
18
IF AMTSND gt 200
cond3 OR cond1 AND cond2
Y
N
IF INVCD A
Y
MOVE OKAY TO MSG
N
IF AMTFST gt 500
Y
N
MOVE OKAY TO MSG
if amtsnd gt 200 or invcd A and amtfst gt 500
move OKAY to msg end if
19
cond1 AND (cond 2 OR cond3)
if invcd A if amtfst gt 500 move
gt500 - OKAY to msg else if amtsnd gt
200 move gt200 -OKAY to msg else
move PROBLEM to msg end if end
if end if
IF INVCD A
Y
N
IF AMTFST gt 500
Y
N
MOVE gt500 - OKAY TO MSG
IF AMTSND gt 200
Y
N
MOVE PROBLEM TO MSG
MOVE gt200 -OKAY TO MSG
20
cond1 AND (cond 2 OR cond3)
if invcd A if amtfst gt 500 move
gt500 - OKAY to msg else if amtsnd gt
200 move gt200 -OKAY to msg else
move PROBLEM to msg end if end
if else move CODE PROBLEM to msg end if
IF INVCD A
Y
N
MOVE CODE PROBLEM TO MSG
IF AMTFST gt 500
Y
N
MOVE gt500 - OKAY TO MSG
IF AMTSND gt 200
Y
N
MOVE PROBLEM TO MSG
MOVE gt200 -OKAY TO MSG
Write a Comment
User Comments (0)
About PowerShow.com