compare

Code


import java.util.Scanner;

public class compare
{
	public static void main( String[] args )
	{
        
        System.out.print("Comparing \"cheese\" with \"cheer\" produces ");
        int i = "cheese".compareTo("dog");
        System.out.println(i);
        
        System.out.print("Comparing \"piano\" with \"riano\" produces ");
        int g = "cheese".compareTo("dog");
        System.out.println(g);
        
        System.out.print("Comparing \"dog\" with \"god\" produces ");
        int b = "cheese".compareTo("dog");
        System.out.println(b);
        
        System.out.print("Comparing \"plane\" with \"tire\" produces");
        System.out.println( "plane".compareTo("tire") );
        System.out.print("Comparing \"bat\" with \"kang\" produces");
        System.out.println( "bat".compareTo("kang") );
        System.out.print("Comparing \"gorilla\" with \"carpet\" produces");
        System.out.println( "gorilla".compareTo("carpet") );
        System.out.print("Comparing \"demon\" with \"car\" produces");
        System.out.println( "demon".compareTo("car") );
        System.out.print("Comparing \"garden\" with \"call\" produces");
        System.out.println( "garden".compareTo("call") );
        System.out.print("Comparing \"gorilla\" with \"carpet\" produces");
        System.out.println( "gorilla".compareTo("carpet") );
        System.out.print("Comparing \"planet\" with \"deep\" produces");
        System.out.println( "planet".compareTo("deep") );
        System.out.print("Comparing \"cat\" with \"cat\" produces");
        System.out.println( "cat".compareTo("cat") );
        System.out.print("Comparing \"ice\" with \"ice\" produces");
        System.out.println( "ice".compareTo("ice") );
        
    }
}

compare

Assignment 50