I have done everything correctly including the else statement at the end..
package com.codegym.task.task04.task0409;
/*
Closest to 10
*/
public class Solution {
public static void main(String[] args) {
displayClosestToTen(8, 11);
displayClosestToTen(7, 14);
}
public static void displayClosestToTen(int a, int b) {
int x = 10 - abs(a);
int y = 10 - b;
if (y < 0)
y = -y;
else
y = y;
if (x < y)
System.out.println(a);
else if (x > y)
System.out.println(b);
else
System.out.println(b);
}
public static int abs(int a) {
if (a < 0) {
return -a;
} else {
return a;
}
}
}