Assignment 50, compareTo() Challenge
Code
///Name: Stella Koliavas
///Period: 5
///Program Name: Gender Game
///File Name: Gendergame.java
///Date Finshed: 11/20/15
public class Compare
{
public static void main (String[]args)
{
System.out.print("Comparing \"axe\" with \"dog\" produces ");
int a = "axe".compareTo("dog");
System.out.println(a);
System.out.print("Comparing \"apple\" with \"banana\" produces ");
int b = "apple".compareTo("banana");
System.out.println(b);
System.out.print("Comparing \"bear\" with \"dog\" produces ");
int c = "bear".compareTo("dog");
System.out.println(c);
System.out.print("Comparing \"stella\" with \"trin\" produces ");
int d = "stella".compareTo("trin");
System.out.println(d);
System.out.print("Comparing \"kappa\" with \"omega\" produces ");
int e = "kappa".compareTo("omega");
System.out.println(e);
System.out.print("Comparing \"zoo\" with \"lemon\" produces ");
System.out.println("zoo".compareTo("apple") );
System.out.print("Comparing \"mine\" with \"cave\" produces ");
int ig = "mine".compareTo("cave");
System.out.println(ig);
System.out.print("Comparing \"outlandish\" with \"normal\" produces ");
int ih = "outlandish".compareTo("normal");
System.out.println(ih);
System.out.print("Comparing \"yahoo\" with \"google\" produces ");
int i = "yahoo".compareTo("google");
System.out.println(ih);
System.out.print("Comparing \"samsung\" with \"apple\" produces ");
int iz = "samsung".compareTo("apple");
System.out.println(iz);
System.out.print("Comparing \"ab\" with \"ab\" produces ");
int ii = "ab".compareTo("ab");
System.out.println(ii);
System.out.print("Comparing \"of\" with \"of\" produces ");
int ij = "of".compareTo("of");
System.out.println(ij);
}
}
Picture of the output