Branching Paths

All the code I have shown you so far has run from top to bottom. That is, it has followed a single "path."

Not all programs can follow a single path though.

Imagine trying to rent a car online. The first thing you might be asked is your age. This is because most car rental companies do not want to rent to people under the age of 25.1.

If you enter an age that is less than 25, the program should immediately tell you that you cannot rent a car. If you enter an age that is greater than or equal to 25, the program should continue to prompt you for more information.

There are multiple "branching paths" that the program might take.

1

For insurance reasons.