AP Practice FRQ #3
You are working at a company and your job is to analyze data. Your company keeps its data stored in Objects of type data (defined below). You do not have access to the source code for data, but rather just a listing of some of the methods and descriptions for how they work. You need to be able to write new methods that can take in a reference to a data Object, and calculate the mean, median and mode. The mean is defined as the average of all values, the median is the value that lies in the center of all of data if sorted in order, and the mode is the value that occurs most commonly. You also must write a method that given a reference to a data object and an open BufferedReader, will read in all values (one per line) from the BufferedReader and add them into the data object.
The partial definition for some methods in data class is as follows:
// returns a value at a given position in the data object (indexes start at 0)
public double getValue(int index)
// sorts the data in a data object in ascending order
public void sort()
// returns the number of occurrences of a given value in the data object
public int valueOccurences(double value)
// returns the number of values stored in the data object
public int size()
// adds a given value into the data object
public void add(double value)
Your methods will have the following headings:
public double getMean(data somedata)
public double getMedian(data somedata)
public double getMode(data somedata)
public void addFile(data somedata, BufferedReader f)
Notes: You can assume all of the imports are handled for you. You also cannot use JOptionPane nor System.out to output values. Use return. You should also assume the BufferedReader is open, but you should STILL have try/catch code in addFile
You are required to do this and show the teacher evidence of your work in order to get 2 points.