Assignment #50

Code

    /// Name: Ian Stanko
    /// Period: 5
    /// Program Name: Compare
    /// File Name: Compare.java
    /// Date Finished: 11/8/2015
    
  public class Compare
  {
        public static void main(String[] args)
        {
            
            //greater than 0
            System.out.print( "Comparing 'harry' to 'jack' produces " );
            System.out.println( "harry".compareTo("jack"));
            System.out.println( "" );
            System.out.print( "Comparing 'harry' to 'kyle' produces " );
            System.out.println( "harry".compareTo("kyle"));
            System.out.println( "" );
            System.out.print( "Comparing 'grant' to 'harry' produces " );
            System.out.println( "grant".compareTo("harry"));
            System.out.println( "" );
            System.out.print( "Comparing 'kyle' to 'jack' produces " );
            System.out.println( "kyle".compareTo("jack"));
            System.out.println( "" );
            System.out.print( "Comparing 'simon' to 'harry' produces " );
            System.out.println( "simon".compareTo("harry"));
            System.out.println( "" );
            
            //less than 0
            System.out.print( "Comparing 'jack' to 'ian' produces " );
            System.out.println( "jack".compareTo("ian"));
            System.out.println( "" );
            System.out.print( "Comparing 'ian' to 'harry' produces " );
            System.out.println( "ian".compareTo("harry"));
            System.out.println( "" );
            System.out.print( "Comparing 'jack' to 'simon' produces " );
            System.out.println( "jack".compareTo("simon"));
            System.out.println( "" );
            System.out.print( "Comparing 'kyle' to 'simon' produces " );
            System.out.println( "kyle".compareTo("simon"));
            System.out.println( "" );
            System.out.print( "Comparing 'kyle' to 'ian' produces " );
            System.out.println( "kyle".compareTo("ian"));
            System.out.println( "" );
            
            //equal to 0
            System.out.print( "Comparing 'ian' to 'ian' produces " );
            System.out.println( "ian".compareTo("ian"));
            System.out.println( "" );
            System.out.print( "Comparing 'kyle' to 'kyle' produces " );
            System.out.println( "kyle".compareTo("kyle"));
            
        
            
        }
    }

    

Picture of the output

Assignment 50