CLASS NOTES:
SD110 Computer Programming Logic
 
 

 

DECISIONS (If-Then-Else)
 
 
OVERVIEW:
 
   


To determine a course of action in a program we must make Decisions. These Decisions generally test whether some Expression is true or not and then follow one path if it is True, and another if it is False. Decisions are commonly called If-Then Statements, or If-Then-Else Statements and they make use of the diamond symbol on a Flowchart.

In the Flowchart (or the Pseudocode) below is a simple Decision. You wish to buy a
certain toy for $9.99, and now you must decide if you can buy that toy or not.

IF the Sum of money you currently have is greater than $10.00, THEN you may buy your toy
ELSE you must wait until you have enough money. Decisions individually are just this simple, but when they are combined into long chains of Decisions they can seem less clear and obvious.

   
     
 
BACK