Takes two ints as parameters. Determines the remainder when the first int is divided by the second. If the remainder is 0 or 1 return true otherwise false.
-----------------------------------------------
public class Class1 {
public static boolean closeEnough (int i, int j) {
//Enter code here
}
}
public class Class1{
public static boolean closeEnough(int i,int j){
if(i%j==0 || i%j==1){
return true;
}else{
return false;
}
}
public static void main(String args[]){
System.out.println(closeEnough(5,4));
System.out.println(closeEnough(5,5));
System.out.println(closeEnough(5,3));
}
}
Get Answers For Free
Most questions answered within 1 hours.