My code always displays the middle number i tested locally.

package com.codegym.task.task04.task0441;
import java.util.Scanner;
/*
Somehow average
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();
int middle = 0;
double avg = (a + b + c) / 3.0;
double smallest = avg;
if (Math.abs(avg -a) < Math.abs(avg-b))
{
smallest = Math.abs(avg -a);
middle = a;
}
else
{
smallest = Math.abs(avg -b);
middle = b;
}
if (Math.abs(avg - c) < smallest)
{
middle = c;
}
if (middle == c)
{
System.out.println(c);
}
else if (middle == b)
{
System.out.println(b);
}
else
{
System.out.println(a);
}
}
}