Project 1, Computing Grades.
Short Description:
Compute a student's grade in a class.
This assignment is worth 30 points.
Goals
When you finish this homework, you should have:
- Written a medium sized program involving multiple files.
- Performed a functional decomposition of a medium sized problem.
- Demonstrated good programming techniques.
- Preformed a reasonably thorough review of programming discussed in your introduction to programming class.
Formal Description
Create a flexible program that will compute the grades for a student based on a configuration file and a series of data files.
The configuration file contains lines of data describing a component of the class, the method used to compute the score for that component, the file containing the data for that component and the weight of that component in the total grade. An example file would be:
Homework points homework.dat 25%
Projects points projects.dat 45%
Tests average test.dat 15%
Final average final.dat 15%
Note that the different fields are separated by one or more spaces. Each line ends with a newline. The file does not contain carriage returns. The file is in proper format but may contain no data.
The fields are as follows
- The component field is a single word, one or more characters in length.
- The method to compute field is a single word.
- It currently contains either points or average but this may change in the future and your program should have the flexibility to accommodate this change.
- Details of the computation methods are provided later.
- If the field contains an unknown value
- print the following error message.
-
Error, invalid computation type error_value.
- So the line
Homework dropLowest lowHomework.dat 10%
should produce the following error:
-
Homework: Error, invalid computation type dropLowest.
(The Homework: portion will be discussed later.)
- Then move to the next line in the control file.
- The data file name is a single word
- This contains the name of the file containing the associated data.
- If this file is missing or empty, your program should
- produce the error
-
Error, empty/invalid file filename.
- So if the file lowHomework.dat is missing or empty, the line
Homework dropLowest lowHomework.dat 10%
should produce the following error:
-
Homework: Error, empty/invalid file lowHomework.dat.
- Then move to the next line in the control file.
- The weight is an integer followed by a percent sign.
- This will be between 0 and 100.
- There will be no errors resulting from the weight field.
The program should begin by prompting the user for the name of the configuration file. Please use the prompt Enter the name of the configuration file: .
If the name of a file that does not exist is supplied
- please report the error message:
-
Error, could not open file_name.
- So if the user attempted to open myfile.data, and this file did not exist, please print
-
Error, could not open myfile.data.
- Then continue to prompt the user for a filename until the name of a file that exists is supplied.
To process a component.
- Print the component name followed by a colon (:) and a space.
- open the individual file for that component
- If the file contains data
- Compute the average of that data as described below
- Print it as a percent accurate to two decimal places.
- Add the weighted percentage to the overall class percentage for the student.
- Add the weight to the class score.
- If there is no data in the file, please report the error
To compute an average when the method to compute is average.
Files of this type contain zero or more integers with values between 0 and 100, followed by a percent sign and separated by one or more whitespace characters. An example file might be
75% 80%
Compute the average by summing all of these numbers and dividing by the number of entries. In the above example, the average would be 77.50%.
0.75 + 0.8 = 1.55
1.55 / 2 = 0.775 = 77.50%
To compute an average when the method to compute is points.
Files of this type contain zero or more entries as follows. Each entry begins with an integer, followed by a / then another integer. Entries are separated by one or more whitespace characters. An example file might be
2/2 4/5
4/6
Compute the average by finding the percent for each entry, adding these percents then dividing by the number of entries. For the above file
2/2 = 100%
4/5 = 80%
4/6 = 66.66%
------
246.66/3 = 82.22%
Computing the final average
For each valid component, multiply the computed average for that component by the weight of that component. Add all of these scores and divide by the total of the weights of the valid components.
For example if the configuration file contains:
Homework points homework.dat 25%
Projects points projects.dat 45%
Tests average test.dat 15%
Final average finals.dat 15%
And the averages are as follows
Homework: 82.22%
Projects: 67.50%
Tests: 77.50%
Final: Error: Could not open finals.dat.
Note, in the example, finals.dat does not exist, so 15% of the class score is not available. The student only has a score for 85% of the class. The final average would be computed as
0.25 * 0.8222 + 0.45 * 0.675 + 0.15 * 0.775 = 0.62555 or 62.56%
Since the final exam did not have data, the score will be out of 85%
0.25 + 0.45 + 0.15 = 0.85 or 85%
The final score will be
0.6256/0.85 = 0.73594 = 73.59%
Your program should finish by reporting the current average, the available percent of the class and the final average. For the above examples the output should be
Average 62.56% out of 85.00%.
Class average 73.59%.
Test Data
Other Notes
Required Files
A single tar file containing the source code and makefile for this program.
Please use this Makefile.
You will have a homework exercise that involves tar before this project is due.
Submission
Submit your tar file to the D2L assignment folder Project1.