Assignment #50 Compare To Challenge
Code
///Name: Ian Grant
///Period:5
///Project Name: Compare To Challenge
///File Name:CompareTo.java
///11/3/15
public class CompareTo
{
public static void main(String[] args)
{
//Five +s
System.out.print("Comparing \"Squirrel\" and \"Breadbox\" produces ");
System.out.println("Squirrel".compareTo("Breadbox"));
System.out.print("Comparing \"Rock\" and \"Regis\" produces ");
System.out.println("Rock".compareTo("Regis"));
System.out.print("Comparing \"Stuff\" and \"Keyboard\" produces ");
System.out.println("Stuff".compareTo("Keyboard"));
System.out.print("Comparing \"Good Cars\" and \"German Cars\" produces ");
System.out.println("Good Cars".compareTo("German Cars"));
System.out.print("Comparing \"Italian Cars\" and \"Good Cars\" produces ");
System.out.println("Italian Cars".compareTo("Good Cars"));
//Two 0s
System.out.print("Comparing \"apple\" and \"apple\" produces ");
System.out.println("apple".compareTo("apple"));
System.out.print("Comparing \"dog\" and \"dog\" produces ");
System.out.println("dog".compareTo("dog"));
//Five -s
System.out.print("Comparing \"Vandermoose\" and \"cat\" produces ");
System.out.println("Vandermoose".compareTo("cat"));
System.out.print("Comparing \"Bob\" and \"Old MacDonald\" produces ");
System.out.println("Bob".compareTo("Old MacDonald"));
System.out.print("Comparing \"Blue\" and \"Red\" produces ");
System.out.println("Blue".compareTo("Red"));
System.out.print("Comparing \"More Stuff\" and \"Stuff\" produces ");
System.out.println("More Stuff".compareTo("Stuff"));
System.out.print("Comparing \"CK2 \" and \"EUIV\" produces ");
System.out.println("CK2".compareTo("EUIV"));
}
}
Output