In your example, there's no real reason to have two separate while
loops. You could have two different case statements in a single loop
or just combine both math operations into a single case. That being
said, you may have a situation where a local variable is called for.
If it's something like a numeric or small string, then the extra
memory is not something to get too worried about. When used correctly,
they can be the best thing to use. It's just that they can be easily
overused and that's why the guidelines say to avoid when possible.