Write a program that asks the user for a file name and counts the number of characters, words, and lines in that file. Then the program asks for the name of the next file. When the user enters a file that doesn't exist, the program prints the total counts of characters, words, and lines in all processed files and exits.

Complete the following files:

FileAnalyzer.java

import java.io.FileNotFoundException; import java.io.File; import java.util.Scanner; /** This class prints a report on the contents of a number of files. */ public class FileAnalyzer { public static void main(String[] args) { Scanner in = new Scanner(System.in); FileCounter counter = new FileCounter(); boolean done = false; while (!done) { . . . counter.read(. . .); . . . } System.out.println("Characters: " + counter.getCharacterCount()); System.out.println("Words: " + counter.getWordCount()); System.out.println("Lines: " + counter.getLineCount()); } }

FileCounter.java

/** A class to count the number of characters, words, and lines in files. */ public class FileCounter { . . . /** Construct a FileCounter object. */ public FileCounter() { . . . } /** Processes an input source and adds its character, word, and line counts to this counter. @param in the scanner to process */ public void read(Scanner in) { . . . } /** Gets the number of words in this counter. @return the number of words */ public int getWordCount() { . . . } /** Gets the number of lines in this counter. @return the number of lines */ public int getLineCount() { . . . } /** Gets the number of characters in this counter. @return the number of characters */ public int getCharacterCount() { . . . } }