Calculating a total price by using switch statement and sentinel controlled loop
Prefer not to use single characters as variable names (except for simple loop counters).  Saving a few keystrokes is not worth it if your readers cannot understand your code.

Based on the context, it looks like n and q should respectively be named productNumber and productQuantity.
The sum += 0 in the default looks unnecessary.  Just remove it if so, even if it's only there to have the default do something.  Keep things simple.