I completed all the requirements expect the last one it's giving me an error: The closeToTen method should display a number on the screen in accordance with the specification. Be sure that the program works correctly with numbers that are equally close to 10.
Requirements:
1. The program should display text on the screen.
2. The main method should not call System.out.println or System.out.print().
3. The main method should call the closeToTen method.
4. The closeToTen method should call the abs method.
5. The closeToTen method should display a number on the screen in accordance with the specification.
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 = 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; } } }