Store Statistics
Overview
- Due:
- 11:00pm, Friday September 4, 2020
- Max grace days:
- 0
The purpose of this assignment is intended demonstrate that you have the prerequisite programming skills for this course. Some of the skills tested are:
- Read data from a file.
- Process the data.
- Print results.
Description
A store needs a program to calculate the sales statistics for each department this year. The store has standard sales amount (in thousand dollars) for each month based on data from previous years.
The monthly sales amounts for departments are stored in a file sales.dat
. Each line in the file contains twelve sales amounts for that department.
Month | Standard |
---|---|
Jan | 23.0 |
Feb | 33.1 |
Mar | 21.0 |
Apr | 23.5 |
May | 54.0 |
Jun | 34.3 |
Jul | 35.0 |
Aug | 45.0 |
Sep | 56.3 |
Oct | 45.6 |
Nov | 34.0 |
Dec | 55.0 |
Write a program to calculate statistics for each department in the store. Your program should do the following:
- Prompt the user for the input file.
- Read the file data into an appropriate data structure, for example, parallel arrays.
- Compute the average monthly sale for each department.
- Compare each monthly sales amount with the standard.
- Output the statistics for the department, including department number, average sales amount, numbers of months above and below the standard, and performance. The program should output “unsatisfied” as the performance of the department if more than four months are below the standard and “satisfied” otherwise.
You may complete this assignment in C, C++, Haskell, Java, OCaml, or Python.
Sample input file
sales.dat
23 33.5 21 23 25 56 54 43 34.2 35.4 34 69.5
24 35.2 24 26 43 56.7 54 32 43 34 34 57.9
24 42 43 35 52 56 67 54 56 45.3 32 32
20 32 45 72 45.4 63.2 45 56 52 65 53 65
34 35 37.5 32 23 45 31 43 52 43 76 65
35 56 63.4 45.2 45.6 56 67.3 45 56.3 67 78 76
34.2 45 62 19 45 39 38 37 82 74 45 58.4
Sample output
Enter file name: sales.dat
Store Statistics
Dept Average Above Below Performance
---- ------- ----- ----- -----------
1 37.6 7 5 unsatisfied
2 38.6 8 4 satisfied
3 44.9 7 5 unsatisfied
4 51.1 8 4 satisfied
5 43.0 7 5 unsatisfied
6 57.6 11 1 satisfied
7 48.2 9 3 satisfied
Turning in the Assignment
You must turn in a file named main.X
where X
is the file extension that follows the convention of the programming language that you chose for your implementation. For example, if you chose Java, then the file must be named main.java
. Submit the program source file to the appropriate folder on D2L.
Grading Criteria
Grading (out of 50 points):
- 5 points – correct file name
- 15 points – reading the file data into an appropriate data structure
- 10 points – correct average output
- 5 points – correct “above” output
- 5 points – correct “below” output
- 10 points – correct “performance” output