/* * Author: Aditya mathur. * Original: September 10, 2008 * Revised; September 14, 2008. [Added some code as this was incomplete.] * * This program illustrates the use of arrays in computing histograms. * Histogram categories are defined, data is generated randomly, histogram is computed and displayed. * */ import java.lang.Double; import java.util.Random; public class Histogram{ public static final int CATEGORIES=5; private double [] boundaries; private int [] histogram; public Histogram() { setCategories(); histogram = new int[CATEGORIES]; } private void setCategories(){ // Histogram Categories: A: <1 B: 1-3, C: 4-6, D: 7-9, E: >9 boundaries = new double[CATEGORIES + 1]; boundaries[0]=Double.NEGATIVE_INFINITY; boundaries[1]=1; boundaries[2]=4; boundaries[3]=7; boundaries[4]=10; boundaries[5]=Double.POSITIVE_INFINITY; } public void compute(double [] data){ for (int i=0; i=boundaries[j] && data[i]