import java.util.*; import java.io.*; public class CountLetters // class to count the number each letter found in a text file (uses a TreeMap), we will use only lower case letters, lower casing any upper case letter { public static void main(String[] args) { String filename; TreeMap map=new TreeMap<>(); // our TreeMap will store the letter as the key and the count of occurrences as the value char current; // current letter being looked at in the file, also used to create our hash map Integer i; // temp Integer variable used when increment the count by 1 String temp; // the next word input for(int j=0;j<26;j++) { current=new Character((char)('a'+j)); // set up the map to have the 26 lower case letters as Characters, with an initial value of 0 map.put(current,0); } try { Scanner in1=new Scanner(System.in); // keyboard input to get the filename System.out.print("Enter the file name: "); filename=in1.next(); Scanner in2=new Scanner(new File(filename)); // file input while(in2.hasNext()) // read the file one String at a time { temp=in2.next().toLowerCase(); // get the next String, lower case it for(int j=0;j