Assignemnt #105 and Evenness Method
Code
/// Name: Kyle Ivy
/// Period: 5
/// Program Name: Evenness
/// File Name: Evenness.java
/// Date Finished: 4/20/2016
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;
}
}
prog105.PNG