PROGRAMMING AND CODE


Assignemnt #105

Code

/// Name: Justin Li
/// Period: 7
/// Program Name: Evenness
/// Date Completed: 2/16/16

public class Evenness
{
    
    public static void main ( String[] args )
    {
        
        for ( int n = 0; n <= 20; n = n + 1 )
        {
            
            if ( isEven(n) == true && isDivisibleBy3(n) == false )
                System.out.println( n + " " + "<" );
            else if ( isEven(n) == false && isDivisibleBy3(n) == true )
                System.out.println( n + " " + "=" );
            else if ( isEven(n) == true && isDivisibleBy3(n) == true )
                System.out.println( n + " " + "<=" );
            else
                System.out.println( n );
        }
    }
    
    
    public static boolean isEven( int n )
    {
        int num = n;
        
        boolean evenBoolean;
        
        if ( num%2 == 0 )
            evenBoolean = true;
        else
            evenBoolean = false;
        
        return evenBoolean;
    }
    
    public static boolean isDivisibleBy3( int n )
    {
        int num = n;
        
        boolean threeBoolean;
        
        if ( num%3 == 0 )
            threeBoolean = true;
        else
            threeBoolean = false;
        
        return threeBoolean;
    }
    

}  
    

Picture of the output

Assignment 1