import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; import uwcse.io.Input; public class FileInput { public static void main(String[] args) { Input in = new Input(); String fileName = in.readString("Enter the file name: "); File file = new File(fileName); try { Scanner scan = new Scanner(file); int[] count = new int[26]; // count[0]: number of a's // count[1]: number of b's while(scan.hasNext()) { String line = scan.nextLine().toLowerCase(); // count the number of a's, b's, etc. for (int i = 0; i < line.length(); i ++) { char c = line.charAt(i); if (c >= 'a' && c <= 'z') { count[c - 'a']++; } } } for (int i = 0; i < count.length; i ++) { System.out.println("Letter " + (char)(i + 'a') + " appears " + count[i] + " times."); } } catch (FileNotFoundException e) { System.out.println("File not found"); } } }