Assignment #105 EvennessMethod
Code
/// Name: Lacey Reese
/// Period: 5
/// Program Name: EvennessMethod
/// File Name: EvennessMethod.java
/// Date Finished 4/11/2016
public class EvennessMethod
{
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