Assignemnt #50: Comparing Strings
Code
/// Name: Sean Harrison
/// Period: 7
/// Program name: Comparing words
/// File Name: CompareTo.java
/// Date Finished: 11/2/2015
public class CompareTo
{
public static void main( String[] args )
{
System.out.print("Comparing \"assault rifle\" with \"assimilation\" produces " );
System.out.println("assault rifle".compareTo("assimilation") );
System.out.print("Comparing \"words\" with \"more words\" produces " ) ;
System.out.println("words".compareTo("more words") );
System.out.print("Comparing \"Jesus\" with \"Buddha\" produces " ) ;
System.out.println("Jesus".compareTo("Buddha" ) );
System.out.print( "Comparing \"meat\" with \"vegetable\" produces " );
System.out.println("meat".compareTo("vegetable" ) );
System.out.print("Comparing \"dog\" with \"bird\" produces " );
System.out.println("dog".compareTo("bird" ) );
System.out.print("Comparing \"methane\" with \"carbon dioxide\" produces " );
System.out.println("methane".compareTo("carbon dioxide" ));
System.out.print("Comparing \"HCL\" with \"HBr\" produces " );
System.out.println("HCL".compareTo("HBr" ));
System.out.print("Comparing \"Tungsten\" with \"Tungsten\" produces " );
System.out.println("Tungsten".compareTo("Tungsten") );
System.out.print("Comparing \"dopamine\" with \"seratonin\" produces " );
System.out.println("dopamine".compareTo("seratonin"));
System.out.print("Comparing \"logic\" with \"reason\" produces " );
System.out.println("logic".compareTo("reason") );
System.out.print("Comparing \"unuseptuim\" with \"unuseptuim\" produces " );
System.out.println("unuseptuim".compareTo("unuseptuim") );
System.out.print("Comparing \"math\" with \"science\" produces " );
System.out.println("math".compareTo("science") );
}
}
Picture of the output