I'm not giving hate to codegym, I just wish they teached us how to do this before they gave us the tasks.
ok ok now. I don't understand this. Please help. And ok, I'll say it, I copied the solution below from another help section.
I understand the lesson, but that doesn't mean I understand the tasks. I understand what to do, but I don't get HOW.
no, but seriously, I need help
package com.codegym.task.task04.task0409;
/*
Closest to 10
*/
public class Solution {
public static void main(String[] args) {
closeToTen(8, 11);
closeToTen(7, 14);
}
public static void closeToTen(int a, int b) {
int a1 = abs(a - 10);
int b1 = abs(b - 10);
if( a1 > b1) {
System.out.println(b);
}
else if (a1 < b1) {
System.out.println(a);
}
else {
System.out.println(a + " " + b);
}
}
public static int abs(int a) {
if (a < 0) {
return -a;
} else {
return a;
}
}
}