I've tried several tests on IntelliJ and they all worked as expected:
Input: 3, 3, 3; Output: 3
Input: 3, 3, 4; Output: 3
Input: 3, 4, 5; Output: 4
Don't understand what I got wrong :(
Any help would be much appreciated!
package com.codegym.task.task04.task0441;
/*
Somehow average
*/
import java.io.*;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n1 = sc.nextInt(), n2 = sc.nextInt(), n3 = sc.nextInt();
int d12 = n1 - n2, d13 = n1 - n3;
if (d12 * d13 <= 0) {
System.out.println(n1);
} else if (Math.abs(d12) <= Math.abs(d13)) {
System.out.println(n2);
} else
System.out.println(n3);
}
}