Assignment #105
Code
///Name: Cody Swain
///Period: 6
///Project Name: Evenness
///File Name:
Evenness.java
///Date: 4/25/16
public class Evenness
{
public static void main( String[] args )
{
System.out.println("1-20 will be printed, with a < is the number is even, and an = f divisible by 3. ");
for ( int n=1; n<21; n++){
System.out.print( n );
if (isEven(n) && isDivisibleBy3(n))
{
System.out.print(" <=");
}
else if ( isEven(n) && isDivisibleBy3(n) == false )
{
System.out.print(" <");
}
else if ( isEven(n) == false && isDivisibleBy3(n) )
{
System.out.print(" =");
}
System.out.println();
}
System.out.println("Done");
}
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