Assignment #50 and Compare To Challenge
Code
/// Name: Graham Pollock
/// Period: 5
/// Program Name: Compare To
/// File Name: CompareTo.java
/// Date Finished: 11/13/2015/
import java.util.*;
public class CompareTo
{
public static void main( String[] args )
{
System.out.print("Comparing \"windows\" with \"mac\" produces ");
int a = "windows".compareTo("mac");
System.out.println(a);
System.out.println();
System.out.print("Comparing \"cat\" with \"dog\" produces ");
int b = "cat".compareTo("dog");
System.out.println(b);
System.out.println();
System.out.print("Comparing \"axe\" with \"tree\" produces ");
int c = "axe".compareTo("tree");
System.out.println(c);
System.out.println();
System.out.print("Comparing \"child\" with \"adult\" produces ");
int d = "child".compareTo("adult");
System.out.println(d);
System.out.println();
System.out.print("Comparing \"mouse\" with \"lion\" produces ");
int e = "mouse".compareTo("lion");
System.out.println(e);
System.out.println();
System.out.print("Comparing \"mountain\" with \"hill\" produces ");
int f = "mountain".compareTo("hill");
System.out.println(f);
System.out.println();
System.out.print("Comparing \"orange\" with \"apple\" produces ");
System.out.println( "orange".compareTo("apple") );
System.out.println();
System.out.print("Comparing \"china\" with \"wall\" produces ");
System.out.println( "china".compareTo("wall") );
System.out.println();
System.out.print("Comparing \"poster\" with \"picture\" produces ");
System.out.println( "poster".compareTo("picture") );
System.out.println();
System.out.print("Comparing \"house\" with \"wall\" produces ");
System.out.println( "house".compareTo("wall") );
System.out.println();
System.out.print("Comparing \"blue\" with \"orange\" produces ");
System.out.println( "blue".compareTo("orange") );
System.out.println();
System.out.print("Comparing \"iphone\" with \"android\" produces ");
System.out.println( "iphone".compareTo("android") );
System.out.println();
}
}
Picture of the output