Assignemnt #50 CompareTo() Challenge
Code
///Name: Prooz Fereydouni
///Period: 7
///Project Name: CompareTo() Challenge
///File Name: CTC.java
///Date: 11/9/2015
public class CTC
{
public static void main( String[] args)
{
int i;
System.out.println("ComparingTo() Challenge");
System.out.println("");
System.out.print("Comparing \"Dog\" to \"Dog\" produces ");
i = "Dog".compareTo("Dog");
System.out.println(i);
System.out.print("Comparing \"Apple\" to \"Apple\" produces ");
i = "Apple".compareTo("Apple");
System.out.println(i);
System.out.print("Comparing \"Dog\" to \"God\" produces ");
i = "God".compareTo("Dog");
System.out.println(i);
System.out.print("Comparing \"Fog\" to \"Dog\" produces ");
i = "Fog".compareTo("Dog");
System.out.println(i);
System.out.print("Comparing \"God\" to \"Fog\" produces ");
i = "God".compareTo("Fog");
System.out.println(i);
System.out.print("Comparing \"Man\" to \"Dog\" produces ");
i = "Man".compareTo("Dog");
System.out.println(i);
System.out.print("Comparing \"Apple\" to \"Anything other than apple\" produces ");
i = "Apple".compareTo("Anything other than apple");
System.out.println(i);
System.out.print("Comparing \"Me\" to \"You\" produces ");
i = "Me".compareTo("You");
System.out.println(i);
System.out.print("Comparing \"Thee\" to \"Thou\" produces ");
i = "Thee".compareTo("Thou");
System.out.println(i);
System.out.print("Comparing \"Sleep\" to \"Work\" produces ");
i = "Sleep".compareTo("Work");
System.out.println(i);
System.out.print("Comparing \"Cat\" to \"Dog\" produces ");
i = "Cat".compareTo("Dog");
System.out.println(i);
System.out.print("Comparing \"Ferrari\" to \"Porche\" produces ");
i = "Ferrari".compareTo("Porche");
System.out.println(i);
}
}
Picture of the output