Assignemnt #50 and compareTo() Challenge
Code
///Name: Luke Shin
///Period: 7
///Project Name: Compare
///File Name: Compare.java
///Date: 11/15/2015
import java.util.Scanner;
import java.util.InputMismatchException;
public class Compare
{
public static void main(String[] args)
{
System.out.println(" This is the compareTo() challenge!!!");
String[][] values =
{{"leg","arm"},
{"run","walk"},
{"stop","start"},
{"table","chair"},
{"good","bad"},
{"right","left"},
{"big", "small"},
{"apple","peach"},
{"six","sixteen"},};
for (int i = 0;i < 9;i++)
{
System.out.println();
System.out.print("Comparing \""+values[i][0]+"\" with \""+values[i][1]+"\" produces ");
System.out.println(values[i][0].compareTo(values[i][1]));
}
}
}
Picture of the output