import java.io.PrintStream; public class Test2BShort { public static void main(String[] args) { PrintStream out = System.out; final String WORD = args[0]; /* Just use InversionCount; if you find two letters that are not in alphabetic order then the word cannot be made up of letters in alphabetic order. Note that the complexity of this solution is O(n*n). An O(n) solution can be written using a single loop; see Test2BShorter.java */ boolean isAlphabetical = true; for (int i = 0; i < WORD.length() - 1; i++) { for (int j = i + 1; j < WORD.length(); j++) { char ci = WORD.charAt(i); char cj = WORD.charAt(j); if (ci > cj) { isAlphabetical = false; } } } out.println(isAlphabetical); } }