Program #105

Code

   
    /// Name: Afaf Nabeeha
    /// Period: 7
    /// Program Name: Evenness Function
    /// File Name: Evenness.java
    /// Date Finished: 3/8/2016 public class Evenness

        public class Evenness
            {
                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;
                }
                
                public static void main ( String[] args )
                {
                    for ( int x = 1 ; x <= 20 ; x++ )
                    {
                        System.out.print( x + " ");
                        
                        if ( isEven(x) == true && isDivisibleBy3(x) == true )
                            System.out.println("<=");
                        else if ( isEven(x) == true )
                            System.out.println("<");
                        else if ( isDivisibleBy3(x) == true )
                            System.out.println("=");
                        else
                            System.out.println();
                    }
                }
            }
             
    

Picture of the output

Assignment 105