Assignemnt #50 CompareTo Challenge
Code
Name: Iaroslav Titov
Period: 7
Project Name: Compare
File Name: Compare.java
Date: 10/21/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"},
{"BIG", "big"},
{"apple","apple tree"},
{"four","ten"},
{"one","one"},
{"two","two"}};
for (int i = 0;i < 12;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