Created
September 25, 2015 04:45
-
-
Save pchhetri/bcc2b32bcb3a2af89934 to your computer and use it in GitHub Desktop.
Simple lexicography
This file contains 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 characters
import java.util.Scanner; | |
public class Lexi { | |
public static void main(String[] args) { | |
Scanner reader = new Scanner(System.in); | |
System.out.println("Please enter your FIRST word: "); | |
String inputA = reader.next(); | |
System.out.println("Please enter your SECOND word: "); | |
String inputB = reader.next(); | |
System.out.println("Please enter your THIRD word: "); | |
String inputC = reader.next(); | |
System.out.println("\nYour inputs were: " + inputA + " " + inputB + " " + inputC); | |
String largest = null; | |
String medium = null; | |
String smallest = null; | |
if(inputA.compareTo(inputB) > 0){ | |
largest = inputA; | |
smallest = inputB; | |
} else { | |
largest = inputB; | |
smallest = inputA; | |
} | |
if(inputC.compareTo(largest) > 0){ | |
largest = inputC; | |
} | |
if(smallest.compareTo(inputC) > 0){ | |
smallest = inputC; | |
} | |
if (inputA.equals(largest) == false && inputA.equals(smallest) == false) { | |
medium = inputA; | |
} else if (inputB.equals(largest) == false && inputB.equals(smallest) == false){ | |
medium = inputB; | |
} else { | |
medium = inputC; | |
} | |
System.out.println("\nResults are:\n" + "Smallest: " + smallest + " Medium: " + medium + " Largest: " + largest); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment