Loading…
Nearly every programming language uses the little word if help to implement a conditional code control structure
We already know that conditional code means that a decision is made about whether a block of code should be carried out as an option
The diagrams below introduce the three variations that the projects in this section will explore in much more detail

1 simple single option


2020-12-15_21-45-43.png
when the dice score is 6 you win
(otherwise simply carry on)
notice there is only one decision and one option
if the diceScore is 6
display a message: you win
end if

2 options: choose one or the other

2020-12-15_21-49-52.png
if the total score is above 70
display a message you are into the next round
else
sorry you are no in the next round
end if
when the total score is more than 70 display a next round message otherwise display sorry message
notice you can’t simply not display anything
notice there is only one decision but two options

3 options

2020-12-15_21-51-44.png
when the weight is more than 200 display cost as 4.50 otherwise a second decision starts: when the weight is over 100 then display cost as 2.50 otherwise the cost is 1.50
notice you can’t simply not display anything
notice there are two decisions but three options

if the weight is over 200g
post cost is 4.50
else
if weight is over 100
post cost is 2.50
else
post cost is 1.50
end if
end if
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.