void closestNumber(array,targetNumber) {
    int minimumDifference = 9999;
    int output = 0;

    for (int i = 0; i < array.length; i++) {
        if (array[i] >= 0 && targetNumber < 0) {
            int temp = array[i] * -1;
            int temptarget = targetNumber * -1;

            if (temptarget > temp) {
                int diff = temptarget - temp;
                minimumDifference = Math.min(minimumDifference, diff);
                output = array[i];
            } else {
                int diff = temp - temptarget;
                minimumDifference = Math.min(minimumDifference, diff);
                output = array[i];
            }
        } 
        else if (array[i] < 0 && targetNumber > 0) {
            int temp = array[i] * -1;

            if (targetNumber > temp) {
                int diff = targetNumber - temp;
                minimumDifference = Math.min(minimumDifference, diff);
                output = array[i];
            } else {
                int diff = temp - targetNumber;
                minimumDifference = Math.min(minimumDifference, diff);
                output = array[i];
            }
        }