Note that the remainder operator in Java is defined such that the magnitude of the result is always less than the magnitude of the divisor, and the result of the remainder operation is negative if the dividend is negative [JLS].
You may obtain the desired output by doing:
output = output + full.charAt((positionP - positionK + 26)%26);
If positionP-positionK
is positive, the addition doesn't change the result (because 26%26=0). If positionP-positionK
is negative (between -25 and 0), then positionP - positionK + 26
will be non-negative, yielding the correct result.