Assignment #50 and Compare To Challenge
Code
///Name: Tim Gibson
///Period: 6
///Project Name: Compare To Challenge
///File Name: CompareToChallenge.java
///Date Finished: 10/13/15
import java.util.Scanner;
public class CompareToChallenge
{
public static void main ( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int a, b, c, d, e, f, g, h, i, j, k, l;
a = "cat".compareTo("dog");
b = "fish".compareTo("lamp");
c = "birds".compareTo("shark");
d = "rat".compareTo("zit");
e = "pizza".compareTo("shoot");
f = "pizzareia".compareTo("pizza");
g = "posterboard".compareTo("poster");
h = "shoestring".compareTo("shoe");
i = "butterfly".compareTo("butter");
j = "waiter".compareTo("wait");
k = "at".compareTo("at");
l = "in".compareTo("in");
System.out.println( "Comparing \"cat\" to \"dog\" produces " + a );
System.out.println( "Comparing \"fish\" to \"lamp\" produces " + b );
System.out.println( "Comparing \"birds\" to \"shark\" produces " + c );
System.out.println( "Comparing \"rat\" to \"zit\" produces " + d );
System.out.println( "Comparing \"pizza\" to \"shoot\" produces " + e );
System.out.println( "Comparing \"pizzareia\" to \"pizza\" produces " + f );
System.out.println( "Comparing \"posterboard\" to \"poster\" produces " + g );
System.out.println( "Comparing \"shoestring\" to \"shoe\" produces " + h );
System.out.println( "Comparing \"butterfly\" to \"butter\" produces " + i );
System.out.println( "Comparing \"waiter\" to \"wait\" produces " + j );
System.out.println( "Comparing \"at\" to \"at\" produces " + k );
System.out.println( "Comparing \"in\" to \"in\" produces " + l );
}
}
Picture of the output