Lab 6: Using JAVA Arrays – Stock Analysis
The purpose of this assignment is to analyze stock prices of Microsoft for a period of one year. The date file of stock prices is given in msft.txt. A typical line in the data file looks as follows:
Date Hi lo close volume
14/05/99 79.938 76.625 76.875 42200500
The methods needed to parse the file will be given in class. We will deal with file inputs at a later point.
The
class Stock has the following methods that need to be completed:
·
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.
·
sort—
Sorts the array of numbers in ascending order (code given)
·
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 -)
Download the lab6.zip file by clicking on this link. Save the zip file to your C:\Temp directory and unzip the files. Open the directory lab6. You should see the following files:
The code in the driver will be given in class. We will go through the design elements as well in class. Upon successfully completing the Stock class, the program should run, generating output that corresponds to the sample output given below.
File msft.txt has been
opened.
76.87
79.12
80.0
79.87
79.68
79.06
77.93
79.12
78.06
79.87
81.31
82.06
82.12
84.0
88.0
86.0
84.93
……..etc
The highest stock price is
94.93
The lowest stock price is
41.81
The average stock price is
64.19
The Return on Investment is
71.91%
The median stock price is
58.1
Press Enter to continue
Your solutions should be in the form of .zip files. When we grade your solution we will unzip the folder and execute the project. If your project does not run you will lose the execution points for that lab.
Your Solution zip file must contain all the files in your projects
Your teaching assistants will show you how to
zip up the files for submission. Instructions are also in the Tutorial
document that is available
Click on this link to Submit your zip file