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) {
int c = abs(a-10);
int d = abs(b-10);
if (c>d) {
System.out.println(b);
}
if (d>c) {
System.out.println(a);
}
if (c==d) {
System.out.println("either of them");
}
}
public static int abs(int a) {
if (a < 0) {
return -a;
}
else {
return a;
}
}
}
What is wrong in my code
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Miki
9 September 2019, 14:14
it's not meant String "either of them" :)
0