Maybe try using a do-while loop for the switch statement and update the value for (a) every time the user input a selection.

sorry couldn't understand your program but try what I said, might work.