/** * * The class models a Stock object * * Name: * Course: * Section: * Last Modified: * Known Bugs: */ import java.io.*; public class Stock { // identify Stock instance variables double [] A = new double[365]; int size; // Default constructor set up an empty Stock object // Second constructor (with parameters)accepts a File of stock prices as input and read the file into the array. public Stock(String filename){ FileInput myFile = new FileInput(fileName); size = 0; while (!myFile.eof()) { String temp = myFile.getString(); int k = temp.indexOf(" "); String date = temp.substring(0,k-1); String next = temp.substring(k); next = next.trim(); k = next.indexOf(" "); String hi = next.substring(0,k-1); next = next.substring(k); next = next.trim(); k = next.indexOf(" "); String lo = next.substring(0,k-1); next = next.substring(k); next = next.trim(); k = next.indexOf(" "); String closingPrice = next.substring(0,k-1); double price = Double.parseDouble(closingPrice); A[size++] = price; } } // sort Sorts the array of numbers in ascending order (code given) public void sort(){ for (int i=0; i A[j+1]) { double temp = A[j]; A[j] = A[j+1]; A[j+1] = temp; } } // max Returns the maximum closing stock price for the year // min Returns the minimum closing stock price for the year // mean Returns the mean closing stock price for the year // median Returns the median closing stock price for the year // ROI compute the return on investment return a percentage as a double (+ or -) // print the list }