Skip to main content

Practice · 1 of 2

The Classifier Switch

CHALLENGE
Difficulty: intermediate+25 XP

Implement classification with ONE switch expression each — no if chains: ``csharp /* "neg" (<0), "zero" (0), "small" (1..99), "large" (>=100) */ static string SizeClass(int n); /* "ok" for "yes"/"no"/"maybe" (any case); "unknown" otherwise */ static string Vote(string? answer); /* Decision table: (hasTicket, isVip, age) -> zone. vip => "gold"; ticket & age>=18 => "standard"; ticket => "minor"; else "deny". */ static string Zone(bool hasTicket, bool isVip, int age); ``

Back to lesson: Practice: Pattern Gym