Assignemnt #105: Evenness Function
Code
/// Name: Kelsey Lieberman
/// Period 5
/// Program Name: EvennessFunction
/// File Name: EvennessFunction.java
/// Date Finished: 2/4/2016
public class EvennessFunction
{
public static void main(String[] args)
{
String sign;
int n;
for ( n = 1; n <= 20; n++ )
{
if (isEven(n) == true && isDivisibleBy3(n) == true)
sign = "<=";
else if (isEven(n) == true)
sign = "<";
else if (isDivisibleBy3(n) == true)
sign = "=";
else
sign = "";
System.out.println( n + " " + sign );
}
}
public static boolean isEven( int n )
{
boolean result;
if (n % 2 == 0)
result = true;
else
result = false;
return result;
}
public static boolean isDivisibleBy3( int n )
{
boolean result;
if (n % 3 == 0)
result = true;
else
result = false;
return result;
}
}
Picture of the output