Assignemnt #50 and CompareToChallenge
Code
/// name: Leila Ordukhani
/// period: 6
/// program name: Thirty-Nine Program
/// file name: CompareToChallenge.java
/// date finished: 11/10/15
import java.util.Scanner;
public class CompareToChallenge
{
public static void main(String[] args)
{
//greater than 0
System.out.print( "Comparing 'coffee' to 'tea' produces " );
System.out.println( "coffee".compareTo("tea"));
System.out.println( "" );
System.out.print( "Comparing 'horses' to 'mice' produces " );
System.out.println( "horses".compareTo("mice"));
System.out.println( "" );
System.out.print( "Comparing 'dogs' to 'cats' produces " );
System.out.println( "dogs".compareTo("cats"));
System.out.println( "" );
System.out.print( "Comparing 'fish' to 'dolphins' produces " );
System.out.println( "fish".compareTo("dolphines"));
System.out.println( "" );
System.out.print( "Comparing 'potatoes' to 'steak' produces " );
System.out.println( "potatoes".compareTo("steak"));
System.out.println( "" );
//less than 0
System.out.print( "Comparing 'forks' to 'knives' produces " );
System.out.println( "forks".compareTo("knives"));
System.out.println( "" );
System.out.print( "Comparing 'pencils' to 'markers' produces " );
System.out.println( "pencils".compareTo("markers"));
System.out.println( "" );
System.out.print( "Comparing 'lion' to 'cougars' produces " );
System.out.println( "lion".compareTo("knights"));
System.out.println( "" );
System.out.print( "Comparing 'dons' to 'knights' produces " );
System.out.println( "dons".compareTo("knights"));
System.out.println( "" );
System.out.print( "Comparing 'tree' to 'money' produces " );
System.out.println( "tree".compareTo("money"));
System.out.println( "" );
//equal to 0
System.out.print( "Comparing 'sponges' to 'sponges' produces " );
System.out.println( "sponges".compareTo("sponges"));
System.out.println( "" );
System.out.print( "Comparing 'hats' to 'hats' produces " );
System.out.println( "hats".compareTo("hats"));
}
}
Picture of the output