static int settleOps(int value, int lastnum, char lastop) {
    switch (lastop) {
    case '%':
      if (lastnum == 0) {
        return INVALID;
      }
      return value % lastnum;
    case '+':
      return value + lastnum;
    case '-':
      return value - lastnum;
    case '/':
      if (lastnum == 0) {
        return INVALID;
      }
      return value / lastnum;
    case '*':
      return value * lastnum;
    case '^':
      return (int) Math.pow(value, lastnum);
    default:
      return lastnum;
    }
  }