The file SalesData.txt contains the dollar amount of sales that a retail store made each day for a number of weeks. Each line in the file contains seven numbers, which are the sales numbers for one week. The numbers are separeted by a comma.
Write a program that opens the file and processes its comments. The program should display the following:
The following is the entire SalesData.txt file from the file.
Breaking it down
The exercise has requirements to display statistics at the weekly level and at the file or total sales level. This exercise could get complicated fast for instance, you could create object to represent the weekly and daily sales or the code could get fairly ugly. We tried to find the balance of each and know that you could reduce the number of lines of code.
In the main method we read the text file and break up each line by a comma creating a List of DoubleSummaryStatistics objects which represents the weekly stats. DoubleSummaryStatistics is an object for collecting statistics such as count, min, max, sum, and average provided in java 8. To get the overall stats, we will call various methods on DoubleSummaryStatistics method and summarize the values.