If you get compiler errors, please copy the full text of the error messages and paste it here.

One problem I see is the variable a needs to be defined outside of the if statements.