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
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
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
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