No if's or while's in a switch case?

No, the syntax is correct, otherwise the compiler would have complained.
It's the semantics that are wrong.