import java.util.*; public class DialogueAnalysis2 { // CHANGE the numbers in here to the correct ones. static int openDouble = 8220; static int closeDouble = 8221; static ArrayList quoteData; public static void main (String[] argv) { // First analyze the text to pull out the dialogue-length data. analyzeText ("huckfinn.txt"); // Build a histogram: int[] histogram = makeHistogram (quoteData); // Then plot part of the histogram: plotHistogram (histogram, 100); } static void analyzeText (String filename) { IOTool.openFileByChar (filename); // Counters: int numCharInQuotes = 0; int numCharOutsideQuotes = 0; // Initialize list to contain data. quoteData = new ArrayList (); boolean inQuote = false; int quoteLength = 0; int k = IOTool.getNextChar (); while (k >= 0) { // INSERT YOUR CODE HERE. k = IOTool.getNextChar (); } System.out.println ("In quotes: " + numCharInQuotes); System.out.println ("Outside quotes: " + numCharOutsideQuotes); } static int[] makeHistogram (ArrayList data) { // INSERT YOUR CODE HERE. // First find the maximum value in the data (in max) int max = 0; // INSERT code for finding max here. // Make an array at least that large. int[] hist = new int [max+1] // Then scan the data and build the histogram. // INSERT the building of the histogram here. // Return the histogram return hist; } static void plotHistogram (int[] hist, int n) { // Plot the first n entries of the histogram int height = 0; for (int i=0; i height) { height = hist[i]; } } DrawTool.display (); DrawTool.setXYRange (0,n, 0,height); for (int i=0; i