import java.util.*; public class histograma { public static void main(String args[]) { /* table mapping strings to integers */ words = new /* ... */; int c = ' '; while (c >= 0) { try { StringBuffer w = new StringBuffer(); do { c = System.in.read(); if (Character.isUpperCase((char) c )) c = Character.toLowerCase((char)c); if (Character.isLowerCase((char) c)) w.append((char)c); else break; } while (true); if (w.length() > 0) { String s = w.toString(); if (/* s is not in words */) /* put [s,0] into words */ /* increment count associated with s in words */ ; } } catch (java.io.IOException e) {c = -1;} } Vector concord = new Vector(); for (/* all [w,c] pairs in words */) /* add WordCounts(w,c) to concord; */ // sort concord into descending order by count; for (int i = 1; i < concord.size(); ++i) { WordCounts element = (WordCounts)concord.get(i); int j = i - 1; while ((j >= 0) && (element.compareTo((WordCounts)concord.get(j)) < 0)) { concord.set(j+1, concord.get(j)); j--; } concord.set(j+1, element); } for (/* all WordCounts wc in concord */) { /* ... */ System.out.println (wc.word + ' ' + wc.count); } } };