Assignemnt #105 and EvennessFunction
Code
/// name: Leila Ordukhani
/// period: 6
/// program name: Ninety-Fourth Program
/// file name: EvennessFunction.java
/// date finished: 3/28/16
import java.util.Scanner;
public class EvennessFunction
{
public static void main(String[] args)
{
for (int n = 1; n <= 20; n++)
{
if (isEven(n) == true && isDivisibleBy3(n) == true)
System.out.println(n + " <=");
else if (isEven(n) == true && isDivisibleBy3(n) == false)
System.out.println(n + " <");
else if (isEven(n) == false && isDivisibleBy3(n) == true)
System.out.println(n + " =");
else
System.out.println(n);
}
}
public static boolean isEven(int n)
{
boolean result;
result = (n % 2 == 0);
return result;
}
public static boolean isDivisibleBy3(int n)
{
boolean result;
result = (n % 3 == 0);
return result;
}
}
Picture of the output