Using Price Data Assignment
The price information data file price.data includes (business day) daily prices for the S&P500 Index (SPX) from 01/01/2004 to 12/31/2004. You are required to write methods described below,
Design a class PriceData that has 2 fields, a String for a date and a double for the price for the index on that date. The date is in the form mm/dd/yyyy. This can be an class in the main class or a separate public class.
loadPriceData: This method should take the file provided as a parameter and load its contents into an ArrayList<PriceData> and return the ArrayList<priceData>. This ArrayList<PriceData> should be used for 3., 4. & 5. below.
getPrices: This method should take a fromDate, a toDate as parameters and returns an ArrayList<Double> of prices of SPX for the period between the fromDate and the toDate. (Inclusive of both dates)
averagePrice: This method should take a fromDate, a toDate and an ArrayList<PriceDate> as parameters and return the average value of SPX for the period between the fromDate and the toDate. (Inclusive of both dates)
maxPrice: This method should take a fromDate, a toDate and an ArrayList<PriceData> as parameters and return the maximum value of SPX for the period between the fromDate and the toDate. (Inclusive of both dates)
getPriceOrder: This method should take a fromDate, a toDate and an ArrayList<PriceData> as parameters and return a List<PriceData> containing all of the price data from fromDate to toDate in order of the prices. For this you should create a class that implements the Comparator<PriceData> interface, get the subList of the ArrayList<PriceData> between the dates, sort the subList using the Collections class sort method with an object of the Comparator<PriceData> class and return the result.
Write a main class that calls these methods and outputs the results of your method calls to a file results.txt and displays the results on a JTextArea in a JScrollPane in a JOptionPane something like
The Prices of SPX between 08/15/2004 and 08/20/2004 are____
The Average Price of SPX between 08/15/2004 and 09/15/2004 is____
The Maximum Price of SPX between 04/15/2004 and 06/15/2004 is____
The Prices of SPX between 01/02/2004 to 01/28/2004 in order were ____