1 / 20

IF Statements flowcharts and pseudocode

IF Statements flowcharts and pseudocode. Please open the speaker notes - they contain additional information!. Simple IF - processing on Y only. IF AMT > 5000. N. Y. AMT x 10 = ANS. if amt > 5000 ans = amt * 10 end if. Simple IF - processing on Y or N. IF AMT > 5000. N. Y.

roddy
Download Presentation

IF Statements flowcharts and pseudocode

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 N Y AMT x 10 = ANS if amt > 5000 ans = amt * 10 end if

  3. Simple IF - processing on Y or N IF AMT > 5000 N Y 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 > 5000 ans = amt * 10 else ans = amt * 5 end if

  4. IF INVCD = “A” AND relationship N Y IF AMT > 5000 Y N MOVE “OKAY” TO MSG if invcd = “A” if amt > 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 N Y IF AMT > 5000 Y N MOVE “OKAY” TO MSG if invcd = “A” if amt > 5000 move “OKAY to msg end if end if if invcd = “A” and amt > 5000 move “OKAY” t0 msg end if

  6. IF INVCD = “A” AND relationship N Y IF AMT > 5000 Y N MOVE “PROBLEM” TO MSG MOVE “PROBLEM” TO MSG MOVE “OKAY” TO MSG 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

  7. IF INVCD = “A” AND relationship N Y IF AMT > 5000 Y N MOVE “PROBLEM” TO MSG MOVE “OKAY” TO MSG if invcd = “A” if amt > 5000 move “OKAY to msg else move “PROBLEM” to msg end if end if

  8. IF INVCD = “A” AND relationship N Y IF AMT > 5000 Y N MOVE “BAD CODE” TO MSG MOVE “PROBLEM” TO MSG MOVE “OKAY” TO MSG 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

  9. IF INVCD = “A” OR relationship N Y MOVE “OKAY” TO MSG IF AMT > 5000 Y N MOVE “OKAY” TO MSG if invcd = “A” move “OKAY” to msg else if amt > 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 > 5000 Y N MOVE “OKAY” TO MSG if invcd = “A” or amt > 5000 move “OKAY to msg end if if invcd = “A” move “OKAY” to msg else if amt > 5000 move “OKAY” to msg end if end if

  11. IF INVCD = “A” OR relationship N Y MOVE “OKAY” TO MSG IF AMT > 5000 Y N MOVE “PROBLEM” TO MSG MOVE “OKAY” TO MSG if invcd = “A” move “OKAY” to msg else if amt > 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 > 5000 Y N MOVE “PROBLEM” TO MSG MOVE “OKAY” TO MSG if invcd = “A” or amt > 5000 move “OKAY to msg else move “PROBLEM” to msg end if if invcd = “A” move “OKAY” to msg else if amt > 5000 move “OKAY” to msg else move “PROBLEM” to msg end if end if

  13. IF INVCD = “A” OR relationship N Y MOVE “CODE - OKAY” TO MSG IF AMT > 5000 Y N MOVE “PROBLEM” TO MSG MOVE “AMT - OKAY” TO MSG if invcd = “A” move “CODE - OKAY” to msg else if amt > 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 > 500 move “OKAY” to msg else if amtsnd > 200 move “OKAY” to msg end if end if end if IF INVCD = “A” N Y IF AMTFST > 500 Y N MOVE “OKAY” TO MSG IF AMTSND > 200 N Y MOVE “OKAY” TO MSG

  15. cond1 AND (cond 2 OR cond3) if invcd = “A” and (amtfst > 500 or amtsnd > 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 > 500 or just amtsnd > 200. N Y IF AMTFST > 500 Y N Continue below MOVE “OKAY” TO MSG IF AMTSND > 200 N Y 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. MOVE “OKAY” TO MSG

  16. cond1 AND (cond 2 OR cond3) if invcd = “A” if amtfst > 500 or amtsnd > 200 move “OKAY” to msg end if end if IF INVCD = “A” N Y IF AMTFST > 500 Y N MOVE “OKAY” TO MSG IF AMTSND > 200 N Y MOVE “OKAY” TO MSG

  17. cond1 AND cond 2 OR cond3 if invcd = “A” and amtfst >500 or amtsnd > 200 move “OKAY” to msg end if IF INVCD = “A” N Y IF AMTSND > 200 N Y IF AMTFST > 500 N Y MOVE “OKAY” TO MSG IF AMTSND > 200 MOVE “OKAY” TO MSG N Y MOVE “OKAY” TO MSG

  18. cond3 OR cond1 AND cond2 IF AMTSND > 200 N Y IF INVCD = “A” Y N MOVE “OKAY” TO MSG IF AMTFST > 500 N Y 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” if amtfst > 500 move “>500 - OKAY” to msg else if amtsnd > 200 move “>200 -OKAY” to msg else move “PROBLEM” to msg end if end if end if IF INVCD = “A” N Y IF AMTFST > 500 N Y MOVE “ >500 - OKAY” TO MSG IF AMTSND > 200 N Y MOVE “PROBLEM” TO MSG MOVE “>200 -OKAY” TO MSG

  20. cond1 AND (cond 2 OR cond3) 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 end if else move “CODE PROBLEM” to msg end if IF INVCD = “A” N Y MOVE “CODE PROBLEM” TO MSG IF AMTFST > 500 N Y MOVE “ >500 - OKAY” TO MSG IF AMTSND > 200 N Y MOVE “PROBLEM” TO MSG MOVE “>200 -OKAY” TO MSG

More Related