Assignemnt #50
Code
/// Name: Daniel Nguyen
/// Period: 6
/// Program Name: compare Program
/// File Name: compare.java
/// Date Finished: 9/9/2015
class compare {
public static void main(String[] args) {
System.out.println("");
System.out.print("Comparing \"donut\" with \"donuthole\" produces ");
System.out.println( "donut".compareTo("donuthole") );
System.out.print("Comparing \"nut\" with \"nuthead\" produces ");
System.out.println( "nut".compareTo("nuthead") );
System.out.print("Comparing \"chic\" with \"chicken\" produces ");
System.out.println( "chic".compareTo("chicken") );
System.out.print("Comparing \"rabbit\" with \"rabbitadcderer\" produces ");
System.out.println( "rabbit".compareTo("rabbitadcderer") );
System.out.print("Comparing \"rain\" with \"rainbow\" produces ");
System.out.println( "rain".compareTo("rainbow") );
System.out.println("");
System.out.print("Comparing \"abcder\" with \"abcdef\" produces ");
System.out.println( "abcder".compareTo("abcdef") );
System.out.print("Comparing \"dcdcdcd\" with \"dcdcdcc\" produces ");
System.out.println( "dcdcdcd".compareTo("dcdcdcc") );
System.out.print("Comparing \"z\" with \"a\" produces ");
System.out.println( "z".compareTo("a") );
System.out.print("Comparing \"walko\" with \"walke\" produces ");
System.out.println( "walko".compareTo("walke") );
System.out.print("Comparing \"woof\" with \"meow\" produces ");
System.out.println( "woof".compareTo("meow") );
System.out.println("");
System.out.print("Comparing \"a\" with \"a\" produces ");
System.out.println( "a".compareTo("a") );
System.out.print("Comparing \"cd\" with \"cd\" produces ");
System.out.println( "cd".compareTo("cd") );
System.out.println("");
}
}
Picture of the output