Program #50

Code

   
    /// Name: Afaf Nabeeha
    /// Period: 7
    /// Program Name: Compare to() Challenge
    /// File Name: Compare.java
    /// Date Finished: 11/25/2015 public class Compare
 
           public class Compare
            {
                public static void main( String[] args )
                {
                    int a;
                    
                    System.out.print("Comparing \"chocolate\" with \"pie\" produces ");
                    a = "chocolate".compareTo("pie");
                    System.out.println(a);
                    
                    System.out.print("Comparing \"afaf\" with \"nabeeha\" produces ");
                    a = "afaf".compareTo("nabeeha");
                    
                    System.out.println(a);
                    
                    System.out.print("Comparing \"dinnertime\" with \"dinner\" produces ");
                    a = "dinnertime".compareTo("dinner");
                    
                    System.out.println(a);
                    
                    System.out.print("Comparing \"lego\" with \"pig\" produces ");
                    a = "lego".compareTo("pig");
                    
                    System.out.println(a);
                    
                    System.out.print("Comparing \"iphone\" with \"android\" produces ");
                    a = "iphone".compareTo("android");
                    
                    System.out.println(a);
                    
                    System.out.print("Comparing \"brother\" with \"sister\" produces ");
                    a = "brother".compareTo("sister");
                    
                    System.out.println(a);
                    
                    System.out.print("Comparing \"tennis\" with \"tennis\" produces ");
                    a = "tennis".compareTo("tennis");
                    
                    System.out.println(a);
                    
                    System.out.print("Comparing \"nike\" with \"kite\" produces ");
                    a = "french".compareTo("spanish");
                    
                    System.out.println(a);
                    
                    System.out.print("Comparing \"computer\" with \"computer\" produces ");
                    a = "computer".compareTo("computer");
                    
                    System.out.println(a);
                    
                    System.out.print("Comparing \"french\" with \"france\" produces ");
                    a = "french".compareTo("france");
                    
                    System.out.println(a);
                    
                    System.out.print("Comparing \"tooth\" with \"teeth\" produces ");
                    a = "tooth".compareTo("teeth");
                    
                    System.out.println(a);
                    
                    System.out.print("Comparing \"math\" with \"hat\" produces ");
                    a = "math".compareTo("hat");
                    
                    System.out.println(a);
                    
                }
          }
                    
                    
 
             
    

Picture of the output

Assignment 50