Assignment #50 and compareToChallenge
Code
/// Name: Jason Kim
/// Period: 7
/// Program Name: compareToChallenge
/// File Name: compareToChallenge.java
/// Date Finished:10/21/15
public class compareToChallenge
{
public static void main (String[] args)
{
System.out.print("Comparing \"hello\" with \"hi\" produces ");
int a = "hello".compareTo("absolute");
System.out.println(a);
System.out.print("Comparing \"ice\" with \"cream\" produces ");
int b = "ice".compareTo("cream");
System.out.println(b);
System.out.print("Comparing \"tail\" with \"dog\" produces ");
int c = "tail".compareTo("dog");
System.out.println(c);
System.out.print("Comparing \"whale\" with \"jam\" produces ");
int d = "whale".compareTo("jam");
System.out.println(d);
System.out.print("Comparing \"tomb\" with \"jeopard\" produces ");
int e = "tomb".compareTo("jeopard");
System.out.println(e);
System.out.print("Comparing \"gorilla\" with \"phone\" produces ");
int f = "gorilla".compareTo("phone");
System.out.println(f);
System.out.print("Comparing \"math\" with \"question\" produces ");
int g = "math".compareTo("question");
System.out.println(g);
System.out.print("Comparing \"biology\" with \"science\" produces ");
int h = "biology".compareTo("science");
System.out.println(h);
System.out.print("Comparing \"chemistry\" with \"physics\" produces ");
int i = "chemistry".compareTo("physics");
System.out.println(i);
System.out.print("Comparing \"test\" with \"zebra\" produces ");
int j = "test".compareTo("zebra");
System.out.println(j);
System.out.print("Comparing \"same\" with \"same\" produces ");
int k = "same".compareTo("same");
System.out.println(k);
System.out.print("Comparing \"something\" with \"something\" produces ");
int l = "something".compareTo("something");
System.out.println(l);
}
}
Picture of the output