Use the switch...case statement when there are several different statements, or groups of statements, where it would be confusing to use a large number of "ifs" and "elses".
The expression is tested, and depending on the value, the corresponding
case is executed. If there is no corresponding case, the
default case is executed.
A common error when using the switch...case statement is to forget that the execution starts in the selected
case, and continues until
break. If you leave out
break, the execution will continue into the next
case.