Once a decision point has been found, the next step is to state exactly what is tested there.
Comparison and Boolean Operators
| Operator | Meaning | Example that is true when age = 16 |
|---|---|---|
| == | Equal to | age == 16 |
| != | Not equal to | age != 18 |
| < and <= | Less than; less than or equal to | age <= 16 |
| > and >= | Greater than; greater than or equal to | age > 12 |
| AND | True only when both conditions are true | age >= 13 AND age <= 19 |
| OR | True when at least one condition is true | age < 5 OR age > 12 |
| NOT | Reverses the result | NOT (age == 18) |
Working Out the Condition for Each Decision
A cinema sells a child ticket to anyone under 13 and a senior ticket to anyone aged 65 or over. Everyone else pays the standard price.
if age < 13 then
ticket = "child"
elseif age >= 65 then
ticket = "senior"
else
ticket = "standard"
end if
| age | age < 13 | age >= 65 | ticket |
|---|---|---|---|
| 12 | True | Not tested | child |
| 13 | False | False | standard |
| 64 | False | False | standard |
| 65 | False | True | senior |