Assignemnt #50 and Compare To Challenge
Code
/// Name: Brian Phillips
/// Period: 5
/// Program name: Compare To Challenge
/// File Name: CompageToChallenge.java
/// Date Finished: 12/2/2015
public class CompareToChallenge
{
public static void main(String[] args)
{
System.out.print("Comparing \"axe\" with \"dog\" produces ");
int i = "axe".compareTo("dog");
System.out.println(i);
System.out.print("Comparing \"car\" with \"cat\" produces ");
System.out.println( "car".compareTo("cat") );
System.out.print("Comparing \"dog\" with \"god\" produces ");
System.out.println( "dog".compareTo("god") );
System.out.print("Comparing \"Questions\" with \"Question\" produces ");
System.out.println( "Questions".compareTo("Question") );
System.out.print("Comparing \"north\" with \"south\" produces ");
System.out.println( "north".compareTo("south") );
System.out.print("Comparing \"word\" with \"ward\" produces ");
System.out.println( "word".compareTo("ward") );
System.out.print("Comparing \"meme\" with \"maymay\" produces ");
System.out.println( "meme".compareTo("maymay") );
System.out.print("Comparing \"this\" with \"that\" produces ");
System.out.println( "this".compareTo("that") );
System.out.print("Comparing \"chair\" with \"chair\" produces ");
System.out.println( "chair".compareTo("chair") );
System.out.print("Comparing \"circle\" with \"sphere\" produces ");
System.out.println( "circle".compareTo("sphere") );
System.out.print("Comparing \"one\" with \"two\" produces ");
System.out.println( "one".compareTo("two") );
System.out.println("Two can be as bad as one it's the lonliest number since the number one" );
System.out.print("Comparing \"abc\" with \"cba\" produces ");
System.out.println( "car".compareTo("cat") );
System.out.print("Comparing \"car\" with \"cat\" produces ");
System.out.println( "its".compareTo("it's") );
}
}
Picture of the output