A utility method to apply an operator ' op ' on operands ' a ' and ' b ' . Return the result .
public static int applyOp ( char op , int b , int a ) { switch ( op ) { case ' + ' : return a + b ; case ' - ' : return a - b ; case ' * ' : return a * b ; case ' / ' : if ( b == 0 ) { throw new System . NotSupportedException ( " Cannot ▁ divide ▁ by ▁ zero " ) ; } return a / b ; } return 0 ; }