Programming Assignment #46
Code
/// Name: Dylan Sleeper
/// Period: 6
/// Program Name: Else and If
/// File Name: adventure.java
/// Date Finished: 10/22/2015
public class compare{
public static void main(String[] args){
System.out.print("Comparing \"apples\" with \"oranges\" produces ");
System.out.println( "apples".compareTo("oranges") );
System.out.print("Comparing \"trumpet\" with \"Sax\" produces ");
System.out.println( "trumpet".compareTo("sax") );
System.out.print("Comparing \"soccer\" with \"basketball\" produces ");
System.out.println( "soccer".compareTo("basketball") );
System.out.print("Comparing \"cat\" with \"dog\" produces ");
System.out.println( "cat".compareTo("dog") );
System.out.print("Comparing \"gate\" with \"gator\" produces ");
System.out.println( "gate".compareTo("gator") );
System.out.print("Comparing \"yes\" with \"no\" produces ");
System.out.println( "yes".compareTo("no") );
System.out.print("Comparing \"unicorn\" with \"rainbows\" produces ");
System.out.println( "unicorn".compareTo("rainbow") );
System.out.print("Comparing \"bill\" with \"bob\" produces ");
System.out.println( "bob".compareTo("bill") );
System.out.print("Comparing \"zoo\" with \"ape\" produces ");
System.out.println( "zoo".compareTo("ape") );
System.out.print("Comparing \"clarinet\" with \"flute\" produces ");
System.out.println( "clarinet".compareTo("flute") );
System.out.print("Comparing \"java\" with \"python\" produces ");
System.out.println( "java".compareTo("python") );
System.out.print("Comparing \"c\" with \"c++\" produces ");
System.out.println( "c".compareTo("c++") );
}
}
Outputs