Separate speaker notes to accompany presentation on ifflowpseudo.ppt which deals with if statements using both flowcharts and pseudocode:

Slide #1:

This is a slide show about IF statements. It will cover both flowcharts and pseudocode.

Slide #2:

This is a simple IF. If the answer to the question is yes then processing is to be done.  If the answer to the question is no then processing is not done.

After the IF is over, we need to close up the IF as shown in the diagram and in the pseudocode.

Note that you can choose to write endif or end if when doing pseudocode.  The then is also optional.

Slide #3:

This is a simple IF.  Different processing will happen depending on the answer to the question.

Note that the yes and the no are joined together at the bottom to indicate that the decision has been terminated.

Slide #4:

This is two IF questions in a simple AND relationship.  This means that both questions have to be true for processing to be done.

INVCD must be = A AND AMT must be > 5000 for processing to be done.  In the simple AND, both answers must be YES.

In this example, the processing is simply moving the word OKAY to a field on the print line or the display screen called MSG.

Slide #5:

Because the no on both of these has no processing, this could be written as a compound.  You can only write a compound if the processing for the no is the same for both questions.

Slide #6:

On this slide the no on both decisions is the same, so again you can use separate questions or a compound.

Slide #7:

In this case, the conditions have different processing if the answer to the question is no. If INVCD is not equal to A, no processing is done.  If AMT > 5000 is no then the PROBLEM message is moved.   Therefore, the questions must be asked individually.  Compound pseudocode or coding cannot be used.

Slide #8:

In this example, the no on both conditions calls for processing, but different messages are moved.  Therefore you must code the if statements separately and you may not use a compound if.

Slide #9:

In this slide, I am demonstrating the simple OR.  Basically this sets up two chances for the message OKAY to be moved to MSG.

IF INVCD is equal to A, then OKAY will be moved to MSG.

If the answer to that question is NO, there is a second chance.  IF AMT is greater than 5000, OKAY will be moved to MSG.

With the simple OR relationship, one or the other has to be true.  With the simple AND relationship, both have to be true.

Slide #10:

Because the yes to both conditions call for the same processing, I can use a compound.

Slide #11:

This shows a message for failing to meet either of the two conditions in the and relationship.  As you will see on the next slide, this could have been handled with a compound.

Slide #12:

In this example if you have tried both conditions and neither of them is true, you move the word PROBLEM to msg.  If either of the conditions is true, you move OKAY. Because you do the same processing if the yes is true, a compound is okay.

Slide #13:

In this example, I am moving a different message for the yes on the invcd question and a different message for the yes on the amt question.  Since the yes processing is different we cannot use compound.  Compound requires that if I get a yes to either question, the processing is the same.

Slide # 14:

This flowchart shows the logic for condition 1 AND either condition 2 OR condition 3.  In the example, INVCD must be equal to A AND then either AMTFST must be greater than 500 OR AMTSND must be greater than 200 so the processing of moving OKAY to the message field can be done.

Put another way:  INVCD must equal A and then if AMTFST > 500, processing will happen.  IF AMTFST is NOT > 500, then I have a second chance.  The second chance is if AMTSND is greater than 200 processing can still be done.

Slide #15:

The condition1 and either condition2 or condition3 can be written in compound because I want to do the same processing no matter as long as condtion1 is true and either condition2 or condition3 are true.

Note that with parenthesis the things within the parenthesis are handled first which means they are grouped and then the thing outside the parenthesis is handled so we end up with condition1 and either condition2 or condition3 which can be stated as invcd="A" and then either amtfst > 500 or amtsnd > 200.

Slide #16:

In this case I have one if that asks about INVCD = A and if that is true, I have another question that asks if either amtst is greater than 500 or amtsnd is greater than 200.  This works equally well.

Slide #17:

Now we are going to look at how this decision would look if we did not use parenthesis when writing the compound. If condition1 and condtion 2 are not true then I need to ask condition3.  In other words if either invcd is not equal to A or amtfst is not greater than 500, I need to ask about amtsnd >200.  Therefore it has to be asked twice.

An alternative would be to ask the question about amtsnd first and then ask the questions about invcd = A and amtfst > 500.  See next slide.

Slide #18:

This shows asking condition3 which stood alone first and then asking for condition1 and condtion2.

Slide #19:

I have now added processing if the answer to amtsnd > 200 is no and changed the processing on the okay moves.  Note that this means I can no longer process this as a compound

Slide #20:

Note the layout is not great for the code problem message, but I had a slide layout problem.