Assignment #105 and Evenness Function
Code
/// Name: Brendan Baird
/// Period: 6
/// Program Name: Evenness Functon
/// File Name: Evenness.java
/// Date Finished: 1/29/2016
public class Evenness
{
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;
}
public static void main ( String[] args )
{
for ( int x = 1 ; x <= 20 ; x++ )
{
System.out.print( x + " ");
if ( isEven(x) == true && isDivisibleBy3(x) == true )
System.out.println("<=");
else if ( isEven(x) == true )
System.out.println("<");
else if ( isDivisibleBy3(x) == true )
System.out.println("=");
else
System.out.println();
}
}
}
Picture of the output