Help me in solving ADJAVA178 problem

My issue

give solution and reson

My code

public class AverageInteger {
    public static int findAverageInteger(int A, int C) {
        // Calculate the average of A and C
        double average = (double) (A + C) / 2;
        
        // Check if the average is an integer
        if (average == (int) average) {
            return (int) average; // Convert it to an integer and return
        } else {
            return -1;
        }
    }

    public static void main(String[] args) {
        // Test cases
        int[][] testCases = {
            {3, 5},
            {3, 6},
            {6, 6},
            {2, 7}
        };

        for (int[] testCase : testCases) {
            int A = testCase[0];
            int C = testCase[1];
            int result = findAverageInteger(A, C);
            System.out.println(result);
        }
    }
}


Learning course: APEC Java
Problem Link: CodeChef: Practical coding for everyone