Conditional statements allow the programmer to specify that a block of code should only be executed if a particular condition is met.
A few comments about the syntax above:
As the example above demonstrates, it can get quite messy to test several conditions. The above code can also be written as shown below using else if conditions.
Following an if, you may have 0 or more else ifs and 0 or 1 else.
Once a condition is satisfied, the rest will not be tested. In the example above, if score is 94, the first condition will be true, the program will print A, and skip the remaining else ifs.
The boolean operators && and || are used to chain together multiple conditions. For example, to determine whether a particular string contains the characters x, y and z, y, you might do the following: