I have done the task using abs value but i would like someone to give me a hint with regards to the use of logical condition in solving this task. I tried using the AND and OR logical operator but i kept getting it wrong.
hello
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Atul Vij
16 September 2019, 23:30
Use the simple if/else condition. I did it like this:
public static void displayClosestToTen(int a, int b) {
// write your code here
if (abs(10-a)<abs(10-b))
System.out.println(a);
else
System.out.println(b);
0