Assignment #105 and Evenness
Code
/// Name: Ali Kurland
/// Period: 6
/// Program Name: Evenness Function
/// File Name: Evenness.java
/// Date Finished: 12/9/2015
public class Evenness
{
public static void main( String[] args )
{
for ( int n=1; n<21; n++ )
{
isEven(n);
isDivisibleBy3(n);
if ( isEven(n) && isDivisibleBy3(n) )
System.out.println( n + " <=" );
else if ( isEven(n) )
System.out.println( n + " <" );
else if ( isDivisibleBy3(n) )
System.out.println( n + " =" );
else
System.out.println( n );
}
}
public static boolean isEven( int n )
{
if ( ( n % 2 ) == 0 )
return true;
else
return false;
}
public static boolean isDivisibleBy3( int n )
{
if ( ( n % 3 ) == 0 )
return true;
else
return false;
}
}
Picture of the output