As an additional comment, the checks for invalid input cases should probably be moved before the switch statement so we exit early when the input is incorrect.