Assignment #50
Code
/// Name: Jonathan Stine
/// Period: 5
/// Program Name: compareTo() Challenge
/// File Name: Challenge.java
/// Date Finished: 1/19/16
public class Challenge {
public static void main( String[] args ) {
System.out.print("Comparing \"boy\" with \"cat\" producues ");
System.out.println("boy".compareTo("cat"));
System.out.print("Comparing \"chocolate\" with \"vanilla\" produces " );
int b = "chocolate".compareTo("vanilla");
System.out.println(b);
System.out.print("Comparing \"shanks\" with \"shivs\" produces " );
int i = "shanks".compareTo("shivs");
System.out.println(i);
System.out.print("Comparing \"giant squid\" with \"sperm whale\" produces " );
int d = "giant squid".compareTo("sperm whale");
System.out.println(d);
System.out.print("Comparing \"Jack\" with \"Paul\" produces " );
int e = "Jack".compareTo("Paul");
System.out.println(e);
System.out.print("Comparing \"peanut butter\" with \"jelly\" produces " );
int c = "peanut butter".compareTo("jelly");
System.out.println(c);
System.out.print("Comparing \"brown eyes\" with \"blue eyes\" produces " );
int f = "brown eyes".compareTo("blue eyes");
System.out.println(f);
System.out.print("Comparing \"ice cream\" with \"frozen yogurt\" produces " );
int g = "ice cream".compareTo("frozen yogurt");
System.out.println(g);
System.out.print("Comparing \"wisdom\" with \"luck\" produces " );
int h = "wisdom".compareTo("luck");
System.out.println(h);
System.out.print("Comparing \"ketchup\" with \"blood\" produces " );
int j = "ketchup".compareTo("blood");
System.out.println(j);
System.out.print("Comparing \"nothing\" with \"nothing\" produces " );
int k = "nothing".compareTo("nothing");
System.out.println(k);
System.out.print("Comparing \"something\" with \"something\" produces " );
int l = "something".compareTo("something");
System.out.println(l);
}
}
Code Output