Last active
November 4, 2015 02:10
-
-
Save mattmccarthy11/b8b5315493fe43efb42c to your computer and use it in GitHub Desktop.
Revisions
-
mattmccarthy11 revised this gist
Nov 4, 2015 . 1 changed file with 44 additions and 59 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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){ 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. */ 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 ); } } -
mattmccarthy11 revised this gist
Nov 4, 2015 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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){ order1 = first; } 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 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 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) -
mattmccarthy11 revised this gist
Nov 4, 2015 . 1 changed file with 13 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,6 @@ import cs1.Keyboard; 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; } System.out.print("The order is as follows: " +order1 +","+order2 +","+order3 +","+order4 ); } } -
mattmccarthy11 created this gist
Nov 3, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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; }