Assignment #105
Code
/// Name: Jonathan Stine
/// Period: 5
/// Program Name: Evenness Function
/// File Name: Evenness.java
/// Date Finished: 4/3/2016
public class Evenness {
public static void main(String[] args) {
for ( int i = 1; i < 21; i++ ) {
System.out.print( "\n" + i + " " );
if (isEven(i) && isDivisibleBy3(i)) {
System.out.print( "<=" );
} else if (isEven(i)) {
System.out.print( "<" );
} else if (isDivisibleBy3(i)) {
System.out.print( "=" );
}
}
}
public static boolean isEven(int n) {
boolean is;
if ( n % 2 == 0 ) {
is = true;
} else {
is = false;
}
return is;
}
public static boolean isDivisibleBy3(int n) {
boolean is;
if ( n % 3 == 0 ) {
is = true;
} else {
is = false;
}
return is;
}
}
Code Output