Assignemnt #105: Evenness Function
Code
/// Name: Cassie
/// Period: 6
/// Program Name: Evenness Function
/// File Name: Evenness.java
/// Date Finished: 3/14/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;
}
}
Picture of the output