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
int x = abs(a);
int y =abs(b);
int c =10 -x;
int d =10-y;
if (c <d)System.out.println(a);
else System.out.println(b);
}
public static int abs(int a) {
if (a < 0) {
return -a;
} else {
return a;
}
}
}
I'm stuck with the last requirement...help me please
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Guadalupe Gagnon
3 December 2019, 03:33
you need to attach your solution or we can not help.
0