/******************************************************************************
* Name: Reference Solutions
* NetID: ref
* Precept: P00
*
* Partner Name: N/A
* Partner NetID: N/A
* Partner Precept: N/A
*
* Description: Reads, prints, and plots stock prices.
*
* Example: java-introcs Prices < TSLA.txt
*
******************************************************************************/
public class Prices {
public static void main(String[] args) {
// Number of trading days
int n = StdIn.readInt();
// For reading
String[] date = new String[n];
double[] open = new double[n];
double[] high = new double[n];
double[] low = new double[n];
double[] close = new double[n];
// Read in daily prices
for (int i = 0; i < n; i++) {
date[i] = StdIn.readString();
open[i] = StdIn.readDouble();
high[i] = StdIn.readDouble();
low[i] = StdIn.readDouble();
close[i] = StdIn.readDouble();
}
// Plot stock price data
StockPlot.plot(open, high, low, close);
// Output the information
StdOut.println(n);
for (int i = 0; i < n; i++) {
StdOut.printf("%s %.2f %.2f %.2f %.2f",
date[i], open[i], high[i], low[i], close[i]);
StdOut.println();
}
}
}