#C13686. Stock Data Analysis

    ID: 43251 Type: Default 1000ms 256MiB

Stock Data Analysis

Stock Data Analysis

You are given a CSV formatted text via standard input (stdin) that contains stock trading data. The first line is the header with the following columns: Date, Open, High, Low, Close, and Volume. Each subsequent line contains the corresponding data for one day. Some rows may be invalid or incomplete. Your task is to process the CSV data and find the date on which the trading volume was the highest and compute the average closing price over all valid rows. A row is valid if both the closing price and the volume can be correctly parsed as a floating-point number and an integer respectively.

The average closing price is computed as [ \text{average} = \frac{\text{total closing price}}{n} ] where (n) is the number of valid rows. If there are no valid rows, output "None" for both the highest volume date and the average closing price.

The output should be printed to standard output (stdout) with the date on the first line and the average closing price on the second line.

inputFormat

The input is provided via standard input (stdin). It consists of several lines of text in CSV format. The first line is the header: 'Date,Open,High,Low,Close,Volume'. Each subsequent line represents one record of stock data. Some rows might be invalid or incomplete.

outputFormat

The program should print two lines to standard output (stdout). The first line is the date with the highest trading volume, and the second line is the average closing price computed from all valid rows. If no valid rows are found, print "None" on each line.## sample

Date,Open,High,Low,Close,Volume
2023-01-01,100,110,90,105,1000
2023-01-02,105,115,95,110,1500
2023-01-03,110,120,100,115,2000
2023-01-04,120,130,110,125,3000
2023-01-04

113.75

</p>