More Examples of the switch Statement

In this lesson, we will look at examples of the switch statement with a character or an enumerated data type.

Character values with a switch statement

The action of a switch statement can be based upon a character. For example, if the char variable grade contains a letter grade, the following switch statement assigns the correct number of quality points to the double variable qualityPoints:

Get hands-on with 1200+ tech skills courses.