• + 0 comments

    java (8)

    static String catAndMouse(int x, int y, int z) {
    
        String result = "Mouse C";
    
        int catA = Math.abs(z - x);
        int catB = Math.abs(z - y);
    
        if (catA > catB) {
            result = "Cat B";
        }
    
        else if (catA < catB) {
    
            result = "Cat A";
    
        }
    
        return result;
    
    }