Assignment # 105 and Evenness
Code
/// Name: Tommy Oyuntseren
/// Period: 7
/// Program Name: Evenness
/// File Name: Evenness.java
/// Date: 5/9/16
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