Assignment #50 CompareTo Challenge
Code
/// Name: John Huh
/// Period: 6
/// Program Name: CompareTo Challenge
/// File Name: Compare.java
/// Date Finished: 11/3/2015
import java.util.Scanner;
public class Compare
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String a1, a2, b1, b2, c1, c2, d1, d2, e1, e2, f1, f2, g1, g2, h1, h2, i1, i2, j1, j2, k1, l1;
int r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12;
a1 = "women";
a2 = "man";
b1 = "happy";
b2 = "sad";
c1 = "mail";
c2 = "zoo";
d1 = "short";
d2 = "tall";
e1 = "harmful";
e2 = "safe";
f1 = "stocky";
f2 = "thin";
g1 = "wary";
g2 = "cautious";
h1 = "truck";
h2 = "car";
i1 = "south";
i2 = "north";
j1 = "beast";
j2 = "animal";
k1 = "walking";
l1 = "tired";
System.out.println();
System.out.print( "Comparing \"women\" with \"man\" produces " );
System.out.println( a1.compareTo(a2) );
System.out.println();
System.out.print( "Comparing \"happy\" with \"sad\" produces " );
System.out.println( b1.compareTo(b2) );
System.out.println();
System.out.print( "Comparing \"mail\" with \"zoo\" produces " );
System.out.println( c1.compareTo(c2) );
System.out.println();
System.out.print( "Comparing \"short\" with \"tall\" produces " );
System.out.println( d1.compareTo(d2) );
System.out.println();
System.out.print( "Comparing \"harmful\" with \"safe\" produces " );
System.out.println( e1.compareTo(e2) );
System.out.println();
System.out.print( "Comparing \"stocky\" with \"thin\" produces " );
System.out.println( f1.compareTo(f2) );
System.out.println();
System.out.print( "Comparing \"wary\" with \"cautious\" produces " );
System.out.println( g1.compareTo(g2) );
System.out.println();
System.out.print( "Comparing \"truck\" with \"car\" produces " );
System.out.println( h1.compareTo(h2) );
System.out.println();
System.out.print( "Comparing \"south\" with \"north\" produces " );
System.out.println( i1.compareTo(i2) );
System.out.println();
System.out.print( "Comparing \"beast\" with \"animal\" produces " );
System.out.println( j1.compareTo(j2) );
System.out.println();
System.out.print( "Comparing \"walking\" with \"walking\" produces " );
System.out.println( k1.compareTo(k1) );
System.out.println();
System.out.print( "Comparing \"tired\" with \"tired\" produces " );
System.out.println( l1.compareTo(l1) );
System.out.println();
}
}
Picture of the output