Skip to content

Instantly share code, notes, and snippets.

@mattmccarthy11
Last active November 4, 2015 02:10
Show Gist options
  • Select an option

  • Save mattmccarthy11/b8b5315493fe43efb42c to your computer and use it in GitHub Desktop.

Select an option

Save mattmccarthy11/b8b5315493fe43efb42c to your computer and use it in GitHub Desktop.

Revisions

  1. mattmccarthy11 revised this gist Nov 4, 2015. 1 changed file with 44 additions and 59 deletions.
    103 changes: 44 additions & 59 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,7 @@

    import cs1.Keyboard;

    public class LexiHell {
    public static void main(String [] args){
    import cs1.Keyboard;
    public class LexiHell {
    public static void main(String [] args){

    System.out.println("Enter the First String");
    String first = Keyboard.readString();
    @@ -15,81 +14,67 @@ public class LexiHell {

    System.out.println("Enter the Fourth String");
    String fourth = Keyboard.readString();


    /*
    The return of this method is an int which can be interpreted as follows:

    returns < 0 then the String calling the method is lexicographically first (comes first in a dictionary)
    returns == 0 then the two strings are lexicographically equivalent
    returns > 0 then the parameter passed to the compareTo method is lexicographically first.
    */


    returns > 0 then the parameter passed to the compareTo method is lexicographically first. */

    String order1 = null;
    String order2 = null;
    String order3 = null;
    String order4 = null;




    //sorting the first string
    if(first.compareTo(second)> 0 && first.compareTo(third) > 0 && first.compareTo(fourth) >0){
    order1 = first;
    }

    else if(first.compareTo(second)>0 && first.compareTo(third) <0 && first.compareTo(fourth) <0){
    order2 =first;
    }

    else if(first.compareTo(second)> 0 && first.compareTo(third) >0 && first.compareTo(fourth) >0){
    order3 =first;
    }

    else if (first.compareTo(second)>0 && first.compareTo(third) > 0 && first.compareTo(fourth) >0){
    order4 =first;
    }

    //sorting the second string

    if(second.compareTo(first)> 0 && second.compareTo(third) >0 && second.compareTo(fourth) >0)
    {
 order1 = second;
}

    

else if(second.compareTo(first)< 0 && second.compareTo(third) >0 && second.compareTo(fourth) >0)
    {
 order2 =second;
}
    

else if(second.compareTo(first)< 0 && second.compareTo(third) <0 && second.compareTo(fourth) >0
    ){
 order3 =second;
}


    else if(second.compareTo(first)< 0 && second.compareTo(third) <0 && second.compareTo(fourth) <0)
    {
 order4 =second;


    }
    //sorting the third string

    if(third.compareTo(first)> 0 && third.compareTo(second) >0 && third.compareTo(fourth) >0)
    {
 order1 = third;
}

    
else if(third.compareTo(first)< 0 && third.compareTo(second) >0 && third.compareTo(fourth) >0)
    {
 order2 =third ;
}
    

else if(third.compareTo(first)< 0 && third.compareTo(second) <0 && third.compareTo(fourth) >0)
    {
 order3 =third;
}

else if(third.compareTo(first)< 0 && third.compareTo(second) <0 && third.compareTo(fourth) <0)
    {
 order4 =third;
}




    //sorting the fourth string

    if(fourth.compareTo(first)> 0 && third.compareTo(second) >0 && third.compareTo(fourth) >0)
    {
 order1 = third;
}
    

else if(fourth.compareTo(first)< 0 && fourth.compareTo(second) >0 && fourth.compareTo(fourth) >0)
    {
 order2 =fourth ;
}


    else if(fourth.compareTo(first)< 0 && fourth.compareTo(second) <0 && fourth.compareTo(fourth) >0)
    {
 order3 =fourth;
}
    

else if(fourth.compareTo(first)< 0 && fourth.compareTo(second) <0 && fourth.compareTo(fourth) <0)
    {
 order4 =fourth;
}



    System.out.print("The order is as follows: " +order1 +","+order2 +","+order3 +","+order4 );


    //sorting the second string

    if(second.compareTo(first)> 0 && second.compareTo(third) >0 && second.compareTo(fourth) >0)
    {order1 = second;}

    else if(second.compareTo(first)< 0 && second.compareTo(third) >0 && second.compareTo(fourth) >0)
    {order2 =second;}
    else if(second.compareTo(first)< 0 && second.compareTo(third) <0 && second.compareTo(fourth) >0)
    {order3 =second;}
    else if(second.compareTo(first)< 0 && second.compareTo(third) <0 && second.compareTo(fourth) <0)
    {order4 =second;}

    //sorting the third string

    if(third.compareTo(first)> 0 && third.compareTo(second) >0 && third.compareTo(fourth) >0)
    {order1 = third;}

    else if(third.compareTo(first)< 0 && third.compareTo(second) >0 && third.compareTo(fourth) >0)
    {order2 =third ;}

    else if(third.compareTo(first)< 0 && third.compareTo(second) <0 && third.compareTo(fourth) >0)
    {order3 =third;}

    else if(third.compareTo(first)< 0 && third.compareTo(second) <0 && third.compareTo(fourth) <0)
    {order4 =third;}

    //sorting the fourth string

    if(fourth.compareTo(first)> 0 && third.compareTo(second) >0 && third.compareTo(fourth) >0)
    {order1 = third;}

    else if(fourth.compareTo(first)< 0 && fourth.compareTo(second) >0 && fourth.compareTo(fourth) >0)
    {order2 =fourth;}

    else if(fourth.compareTo(first)< 0 && fourth.compareTo(second) <0 && fourth.compareTo(fourth) >0)
    {order3 =fourth;}

    else if(fourth.compareTo(first)< 0 && fourth.compareTo(second) <0 && fourth.compareTo(fourth) <0)
    {order4 =fourth;}

    System.out.print("The order is as follows: " +order1 +","+order2 +","+order3 +","+order4 );
    }
    }




    }
  2. mattmccarthy11 revised this gist Nov 4, 2015. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -35,11 +35,11 @@ public class LexiHell {


    //sorting the first string
    if(first.compareTo(second)< 0 && first.compareTo(third) <0 && first.compareTo(fourth) <0){
    if(first.compareTo(second)> 0 && first.compareTo(third) > 0 && first.compareTo(fourth) >0){
    order1 = first;
    }

    else if(first.compareTo(second)<0 && first.compareTo(third) <0 && first.compareTo(fourth) <0){
    else if(first.compareTo(second)>0 && first.compareTo(third) <0 && first.compareTo(fourth) <0){
    order2 =first;
    }

    @@ -50,8 +50,8 @@ public class LexiHell {
    else if (first.compareTo(second)>0 && first.compareTo(third) > 0 && first.compareTo(fourth) >0){
    order4 =first;
    }
    
//sorting the second string


    //sorting the second string

    if(second.compareTo(first)> 0 && second.compareTo(third) >0 && second.compareTo(fourth) >0)
    {
 order1 = second;
}

    @@ -63,7 +63,7 @@ else if(second.compareTo(first)< 0 && second.compareTo(third) <0 && second.compa
    {
 order4 =second;


    }
    

//sorting the third string

    //sorting the third string

    if(third.compareTo(first)> 0 && third.compareTo(second) >0 && third.compareTo(fourth) >0)
    {
 order1 = third;
}

    
else if(third.compareTo(first)< 0 && third.compareTo(second) >0 && third.compareTo(fourth) >0)
  3. mattmccarthy11 revised this gist Nov 4, 2015. 1 changed file with 13 additions and 4 deletions.
    17 changes: 13 additions & 4 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,6 @@

    import cs1.Keyboard;

    /**
    * Created by mattmccarthy on 11/3/15.
    */
    public class LexiHell {
    public static void main(String [] args){

    @@ -83,4 +80,16 @@ if(fourth.compareTo(first)> 0 && third.compareTo(second) >0 && third.compareTo(f
    else if(fourth.compareTo(first)< 0 && fourth.compareTo(second) <0 && fourth.compareTo(fourth) >0)
    {
 order3 =fourth;
}
    

else if(fourth.compareTo(first)< 0 && fourth.compareTo(second) <0 && fourth.compareTo(fourth) <0)
    {
 order4 =fourth;
}
    {
 order4 =fourth;
}



    System.out.print("The order is as follows: " +order1 +","+order2 +","+order3 +","+order4 );


    }
    }




  4. mattmccarthy11 created this gist Nov 3, 2015.
    86 changes: 86 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,86 @@

    import cs1.Keyboard;

    /**
    * Created by mattmccarthy on 11/3/15.
    */
    public class LexiHell {
    public static void main(String [] args){

    System.out.println("Enter the First String");
    String first = Keyboard.readString();

    System.out.println("Enter the Second String");
    String second = Keyboard.readString();

    System.out.println("Enter the Third String");
    String third = Keyboard.readString();

    System.out.println("Enter the Fourth String");
    String fourth = Keyboard.readString();


    /*
    The return of this method is an int which can be interpreted as follows:

    returns < 0 then the String calling the method is lexicographically first (comes first in a dictionary)
    returns == 0 then the two strings are lexicographically equivalent
    returns > 0 then the parameter passed to the compareTo method is lexicographically first.
    */


    String order1 = null;
    String order2 = null;
    String order3 = null;
    String order4 = null;




    //sorting the first string
    if(first.compareTo(second)< 0 && first.compareTo(third) <0 && first.compareTo(fourth) <0){
    order1 = first;
    }

    else if(first.compareTo(second)<0 && first.compareTo(third) <0 && first.compareTo(fourth) <0){
    order2 =first;
    }

    else if(first.compareTo(second)> 0 && first.compareTo(third) >0 && first.compareTo(fourth) >0){
    order3 =first;
    }

    else if (first.compareTo(second)>0 && first.compareTo(third) > 0 && first.compareTo(fourth) >0){
    order4 =first;
    }
    
//sorting the second string


    if(second.compareTo(first)> 0 && second.compareTo(third) >0 && second.compareTo(fourth) >0)
    {
 order1 = second;
}

    

else if(second.compareTo(first)< 0 && second.compareTo(third) >0 && second.compareTo(fourth) >0)
    {
 order2 =second;
}
    

else if(second.compareTo(first)< 0 && second.compareTo(third) <0 && second.compareTo(fourth) >0
    ){
 order3 =second;
}


    else if(second.compareTo(first)< 0 && second.compareTo(third) <0 && second.compareTo(fourth) <0)
    {
 order4 =second;


    }
    

//sorting the third string

    if(third.compareTo(first)> 0 && third.compareTo(second) >0 && third.compareTo(fourth) >0)
    {
 order1 = third;
}

    
else if(third.compareTo(first)< 0 && third.compareTo(second) >0 && third.compareTo(fourth) >0)
    {
 order2 =third ;
}
    

else if(third.compareTo(first)< 0 && third.compareTo(second) <0 && third.compareTo(fourth) >0)
    {
 order3 =third;
}

else if(third.compareTo(first)< 0 && third.compareTo(second) <0 && third.compareTo(fourth) <0)
    {
 order4 =third;
}




    //sorting the fourth string

    if(fourth.compareTo(first)> 0 && third.compareTo(second) >0 && third.compareTo(fourth) >0)
    {
 order1 = third;
}
    

else if(fourth.compareTo(first)< 0 && fourth.compareTo(second) >0 && fourth.compareTo(fourth) >0)
    {
 order2 =fourth ;
}


    else if(fourth.compareTo(first)< 0 && fourth.compareTo(second) <0 && fourth.compareTo(fourth) >0)
    {
 order3 =fourth;
}
    

else if(fourth.compareTo(first)< 0 && fourth.compareTo(second) <0 && fourth.compareTo(fourth) <0)
    {
 order4 =fourth;
}