hello, I made a program that works well, but last check never turns green. I checked the distance from +10, so a -3(example) Is 13 from +10, a +8 (example) is only 2 from +10. Am i wrong with my impostation?
package com.codegym.task.task04.task0409;
/*
Closest to 10
*/
public class Solution {
public static void main(String[] args) {
displayClosestToTen(8, 11);
displayClosestToTen(7, 14);
displayClosestToTen(23, 23);
displayClosestToTen(-3, -8);
}
public static void displayClosestToTen(int a, int b) {
// write your code here
int realA = a;
int realB = b;
a = tenner(a);
b = tenner(b);
a = abs(a);
b = abs(b);
if (a<b) {
System.out.println(realA);
}
else {
if (b<a) {
System.out.println(realB);
}
else {
System.out.println(realA + " " + realB);
}
}
}
public static int abs(int a) {
if (a < 0) {
return -a;
}
else {
return a;
}
}
public static int tenner(int a) {
if (a!=0) {
a=a-10;
}
else {
a=10;
}
return a;
}
}