Rand function and switch statement