public int divide(int dividend, int divisor) {
        int cnt = 0;
        boolean dividendN = false, divisorN = false;
        if (dividend < 0) {
            dividendN = true;
            dividend *= -1;
        }
        if (divisor < 0) {
            divisorN = true;
            divisor *= -1;
        }
        while (dividend >= divisor) {
            dividend -= divisor;
            cnt = cnt+1;
        }
        if ( (dividendN && !divisorN) || (!dividendN && divisorN) )
            cnt *= -1;
        return cnt;
    }