compareTo() Challenge
Code
/// Name: Mahima Choudhary
/// Period: 5
/// Program Name: compareTo() Challenge
/// File Name: Challenge.java
/// Date Finished: 11/24/2015
public class Challenge {
public static void main( String[] args ) {
System.out.print("Comparing \"Peanut Butter\" with \"Jelly\" produces " );
int a = "Peanut Butter".compareTo("Jelly");
System.out.println(a);
System.out.print("Comparing \"black\" with \"white\" produces " );
int b = "black".compareTo("white");
System.out.println(b);
System.out.print("Comparing \"Mahi\" with \"Katie\" produces " );
int i = "Mahi".compareTo("Katie");
System.out.println(i);
System.out.print("Comparing \"Simba\" with \"Lion King\" produces " );
int d = "Simba".compareTo("Lion King");
System.out.println(d);
System.out.print("Comparing \"Aladdin\" with \"Jasmine\" produces " );
int e = "Aladdin".compareTo("Jasmine");
System.out.println(e);
System.out.print("Comparing \"pudding\" with \"jello\" produces " );
int c = "pudding".compareTo("jello");
System.out.println(c);
System.out.print("Comparing \"dogs\" with \"cats\" produces " );
int f = "dogs".compareTo("cats");
System.out.println(f);
System.out.print("Comparing \"pepsi\" with \"coke\" produces " );
int g = "pepsi".compareTo("coke");
System.out.println(g);
System.out.print("Comparing \"chocolate\" with \"vanilla\" produces " );
int h = "chocolate".compareTo("vanilla");
System.out.println(h);
System.out.print("Comparing \"burgers\" with \"hotdogs\" produces " );
int j = "burgers".compareTo("hotdogs");
System.out.println(j);
System.out.print("Comparing \"water\" with \"water\" produces " );
int k = "water".compareTo("water");
System.out.println(k);
System.out.print("Comparing \"books\" with \"books\" produces " );
int l = "books".compareTo("books");
System.out.println(l);
}
}
Picture of the output