Download presentation
Presentation is loading. Please wait.
Published byEmory Hubbard Modified over 8 years ago
1
IF Statements flowcharts and pseudocode Please open the speaker notes - they contain additional information!
2
Simple IF - processing on Y only IF AMT > 5000 Y AMT x 10 = ANS N if amt > 5000 ans = amt * 10 end if
3
Simple IF - processing on Y or N IF AMT > 5000 Y ANS= AMT x 10 N ANS = AMT x 5 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 > 5000 ans = amt * 10 else ans = amt * 5 end if
4
IF INVCD = “A” Y MOVE “OKAY” TO MSG N IF AMT > 5000 Y N AND relationship if invcd = “A” if amt > 5000 move “OKAY to msg 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” Y MOVE “OKAY” TO MSG N IF AMT > 5000 Y N AND relationship if invcd = “A” if amt > 5000 move “OKAY to msg end if if invcd = “A” and amt > 5000 move “OKAY” t0 msg end if
6
IF INVCD = “A” Y MOVE “OKAY” TO MSG N IF AMT > 5000 Y N AND relationship if invcd = “A” if amt > 5000 move “OKAY to msg else move “PROBLEM” to msg end if else move “PROBLEM” to msg end if if invcd = “A” and amt > 5000 move “OKAY” to msg else move “PROBLEM” to msg end if MOVE “PROBLEM” TO MSG MOVE “PROBLEM” TO MSG
7
IF INVCD = “A” Y MOVE “OKAY” TO MSG N IF AMT > 5000 Y N AND relationship if invcd = “A” if amt > 5000 move “OKAY to msg else move “PROBLEM” to msg end if MOVE “PROBLEM” TO MSG
8
IF INVCD = “A” Y MOVE “OKAY” TO MSG N IF AMT > 5000 Y N AND relationship if invcd = “A” if amt > 5000 move “OKAY to msg else move “PROBLEM” to msg end if else move “BAD CODE” to msg end if MOVE “PROBLEM” TO MSG MOVE “BAD CODE” TO MSG
9
IF INVCD = “A” Y MOVE “OKAY” TO MSG IF AMT > 5000 Y N N MOVE “OKAY” TO MSG OR relationship if invcd = “A” move “OKAY” to msg else if amt > 5000 move “OKAY” to msg end if One or the other of the if questions must be true for OKAY to be moved to msg.
10
IF INVCD = “A” Y MOVE “OKAY” TO MSG IF AMT > 5000 Y N N MOVE “OKAY” TO MSG OR relationship if invcd = “A” move “OKAY” to msg else if amt > 5000 move “OKAY” to msg end if if invcd = “A” or amt > 5000 move “OKAY to msg end if
11
IF INVCD = “A” Y MOVE “OKAY” TO MSG IF AMT > 5000 Y N N MOVE “OKAY” TO MSG MOVE “PROBLEM” TO MSG OR relationship if invcd = “A” move “OKAY” to msg else if amt > 5000 move “OKAY” to msg else move “PROBLEM” to msg end if
12
IF INVCD = “A” Y MOVE “OKAY” TO MSG IF AMT > 5000 Y N N MOVE “OKAY” TO MSG OR relationship if invcd = “A” move “OKAY” to msg else if amt > 5000 move “OKAY” to msg else move “PROBLEM” to msg end if if invcd = “A” or amt > 5000 move “OKAY to msg else move “PROBLEM” to msg end if MOVE “PROBLEM” TO MSG
13
IF INVCD = “A” Y MOVE “AMT - OKAY” TO MSG IF AMT > 5000 Y N N MOVE “CODE - OKAY” TO MSG MOVE “PROBLEM” TO MSG OR relationship if invcd = “A” move “CODE - OKAY” to msg else if amt > 5000 move “AMT - OKAY” to msg else move “PROBLEM” to msg end if
14
cond1 AND (cond 2 OR cond3) IF INVCD = “A” Y MOVE “OKAY” TO MSG N IF AMTFST > 500 Y N IF AMTSND > 200 MOVE “OKAY” TO MSG YN if invcd = “A” if amtfst > 500 move “OKAY” to msg else if amtsnd > 200 move “OKAY” to msg end if
15
cond1 AND (cond 2 OR cond3) IF INVCD = “A” Y MOVE “OKAY” TO MSG N IF AMTFST > 500 Y N IF AMTSND > 200 MOVE “OKAY” TO MSG YN if invcd = “A” and (amtfst > 500 or amtsnd > 200) move “OKAY” to msg end if 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 > 500 or just amtsnd > 200. We want the logic to be invcd = A and either amtfst > 500 or amtsnd >200. 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. Continue below
16
IF INVCD = “A” Y MOVE “OKAY” TO MSG N IF AMTFST > 500 Y N IF AMTSND > 200 MOVE “OKAY” TO MSG YN if invcd = “A” if amtfst > 500 or amtsnd > 200 move “OKAY” to msg end if cond1 AND (cond 2 OR cond3)
17
IF INVCD = “A” Y MOVE “OKAY” TO MSG N IF AMTFST > 500 YN IF AMTSND > 200 MOVE “OKAY” TO MSG YN cond1 AND cond 2 OR cond3 IF AMTSND > 200 MOVE “OKAY” TO MSG YN if invcd = “A” and amtfst >500 or amtsnd > 200 move “OKAY” to msg end if
18
IF AMTSND > 200 MOVE “OKAY” TO MSG YN cond3 OR cond1 AND cond2 IF INVCD = “A” Y N IF AMTFST > 500 YN MOVE “OKAY” TO MSG if amtsnd > 200 or invcd = “A” and amtfst > 500 move “OKAY” to msg end if
19
cond1 AND (cond 2 OR cond3) IF INVCD = “A” Y MOVE “ >500 - OKAY” TO MSG N IF AMTFST > 500 YN IF AMTSND > 200 MOVE “>200 -OKAY” TO MSG YN if invcd = “A” if amtfst > 500 move “>500 - OKAY” to msg else if amtsnd > 200 move “>200 -OKAY” to msg else move “PROBLEM” to msg end if MOVE “PROBLEM” TO MSG
20
cond1 AND (cond 2 OR cond3) IF INVCD = “A” Y MOVE “ >500 - OKAY” TO MSG N IF AMTFST > 500 YN IF AMTSND > 200 MOVE “>200 -OKAY” TO MSG YN if invcd = “A” if amtfst > 500 move “>500 - OKAY” to msg else if amtsnd > 200 move “>200 -OKAY” to msg else move “PROBLEM” to msg end if else move “CODE PROBLEM” to msg end if MOVE “PROBLEM” TO MSG MOVE “CODE PROBLEM” TO MSG
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.