I'm not sure what I'm doing wrong. It evaluates the numbers and when I run it in the out put window it shows the number from the println command but I still keep getting errors saying it should display a number.
public class Solution {
public static void main(String[] args) {
displayClosestToTen(8, 11);
displayClosestToTen(7, 14);
}
public static void displayClosestToTen(int a, int b) {
// write your code here
a = abs(a-10);
b = abs(b-10);
if(a > b){
System.out.println(a);
}else if(b > a){
System.out.println(b);
}else{
System.out.println(a);
}
}
public static int abs(int a) {
if (a < 0) {
return -a;
} else {
return a;
}
}
}
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) {
// write your code here
a = abs(a-10);
b = abs(b-10);
if(a > b){
System.out.println(a);
}else if(b > a){
System.out.println(b);
}else{
System.out.println(a);
}
}
public static int abs(int a) {
if (a < 0) {
return -a;
} else {
return a;
}
}
}