import java.io.*; import java.util.*; /** * A simple calculator that can be used to calculate * descriptive statistics from a sample contained in a file * * @author Prof. David Bernstein, James Madison University * @version 2.0 (Using type-safe generics) */ public class StatisticsCalculator { private Vector values; // v2.0 /** * Explicit Value Constructor * * @param name The name of the file containing the sample */ public StatisticsCalculator(String name) throws IOException { double value; Scanner in; // Initialize the Vector values = new Vector(); // Read the data in = new Scanner(new File(name)); while (in.hasNext()) { value = in.nextDouble(); values.add(value); // v2.0 (boxing) } } /** * Calculates the mean of a sample * * @return The mean */ public double mean() { double total, value; total = 0.0; for (int i=0; i