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
abs(a);
abs(b);
int c,d;
c=a%5;
d=b%5;
if(c<d){
System.out.println(a);
}
else 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;
}
}
}
Whats Wrong here.....output is correct...only last condition is not satisfied!??
whats wrong in this code ?
Resolved
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Misiu
11 April 2020, 13:07solution
-7, -14
Your code returns -14. This is incorrect.
0