Question: Write program for the exercise 11(Sales Analysis) as explained at the end of the chapter. 11. sales Analysis The file SalesData.txt, in this chapters source
Write program for the exercise 11(Sales Analysis) as explained at the end of the chapter.
11. sales Analysis The file SalesData.txt, in this chapters source code folder, 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 separated by a comma. The following line is an example from the file: 2541.36,2965.88,1965.32,1845.
The total sales for each week
The average daily sales for each week
The total sales for all of the weeks
The average weekly sales
The week number that had the highest amount of sales
The week number that had the lowest amount of sales
Other Requirements:
The program file name must be: SalesAnalysisDemo.java
The data file that your program opens must be named as: SalesData.txt
There are different ways you can round numbers in java. Here is sample way of rounding the numbers to two digts after decimal point.
// Display the total sales for each week.
System.out.printf("Weekly sales from week " + weekNumber + " is "
+ "$%.2f " , total);
// Display the sales average.
System.out.printf("Average for week " + weekNumber + " is $%.2f " ,
average);
Sample Data File attached here SalesData.txt
Test Case:
Weekly sales from week 1 is $12092.75
Average for week 1 is $1727.54
Weekly sales from week 2 is $27461.00
Average for week 2 is $3923.00
Weekly sales from week 3 is $12058.34
Average for week 3 is $1722.62
Weekly sales from week 4 is $13141.70
Average for week 4 is $1877.39
Weekly sales from week 5 is $18366.92
Average for week 5 is $2623.85
Weekly sales from week 6 is $12058.34
Average for week 6 is $1722.62
Total sale of all weeks = 95179.05
Average weekly sales = 15863.17
The week number with the highest amount of sales is: 2
The week number with the lowest amount of sales is: 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
