Assignment #105: Evenness Function
Code
public class Divisibility {
public static void main(String[] args) {
for (int a = 1; a <= 20; a++) {
System.out.println();
System.out.print(a + " ");
if (isEven(a)) {
System.out.print("<");
}
if (isDivisible3(a)) {
System.out.print("=");
}
}
}
public static boolean isEven(int n) {
if ((n % 2) == 0) {
return true;
}
else {
return false;
}
}
public static boolean isDivisible3(int x) {
if ((x % 3) == 0) {
return true;
}
else {
return false;
}
}
}
Picture of the output