Lab 6 |
Week of 10/19/04-10/25/04150 Points |
Averages and Medians |
Due in lab week of
|
Open and read a file with student’s scores for a semester. Display a chart with the average and median scores for each section and each lab.
Example: CS 111 this semester has 7 sections and 10 labs. The output will be a chart with 7 rows and 20 columns. Seven rows for sections 1 to 7. Two columns (average and median) for each of the 10 labs.
Note: The average is rounded up to the nearest integer you must write your own function int myCeil(double n) that takes say 1.01 and returns 2 or takes 1.0 and returns 1
Name: “in.txt” you must use the name in.txt
First line 2 integers:
For Each Section
First Line, 1 Integer: N The number of students in the section <= 50
For each Student
Student Id L1 L2 … LNumLabs
Student Id: 4 digit integer
Labs scores: Integers 0 to 100
Example: A small class with 3 sections and 4 labs.
The first section has 4 students, the second 5 and the third 4
3 4
4
8591 87 60 82 64
1881 95 63 75 94
6758 71 56 72 63
7541 65 95 84 87
5
3690 88 86 99 68
3515 78 60 98 53
1534 91 95 65 81
2459 86 69 79 50
7047 70 61 63 71
4
6204 89 98 56 69
6437 92 67 95 87
2012 67 97 66 54
8147 90 50 63 100
|
Lab |
1 |
Lab |
2 |
Lab |
3 |
Lab |
4 |
|
A |
M |
A |
M |
A |
M |
A |
m |
1 |
80 |
87 |
69 |
63 |
79 |
82 |
77 |
87 |
2 |
83 |
86 |
75 |
69 |
81 |
79 |
65 |
68 |
3 |
85 |
90 |
78 |
97 |
70 |
66 |
78 |
87 |
i. int output[10][20]; Where the rows are the sections, and the columns are the averages and the medians for the labs.
OR
ii. int output[10][10][2]; output[x][y][z]
1. where x is the sections
2. y is the labs
3. z =0 is the average and z=1 is the median
Don’t forget the usual documentation requirements. The overall program needs a clearly stated purpose. The program must have a header identifying the assignment, due date, programmer, etc. Functions need stated purpose and pre- and post- conditions.
You can test your program on the data file in.txt
.
Be careful that you aren’t copying code from anyone or allowing anyone to view your own code. Be careful with hard copy and electronic copy. You would be amazed at the number of plagiarism and complicity charges that arise when one person “loans” copy to another to “get an idea how to do it” only to have the recipient copy and submit the coded directly. Discussion of ideas about solutions is okay – just don’t code together.