Project 2 - A Grade Calculator
Due - Monday, October 23, 2006
The goal of this project is to give you experience using
iteration, file i/o, classes, and lists. You will write a program
that reads from a file each student's project and exam scores,
builds a database of the information, calculates the final course
grade for each student, and determines the minimum, maximum, and
average grades for the class. The output of your program will be a
text file containing the name and final grade for each student,
the names and grades of the students with the minimum score and
maximum score, and the average score of the class.
The input file from which your program will read will contain one
line for each student. Each line will have nine space-delineated
fields denoting the name, project 1 score, project 2 score,
project 3 score, project 4 score, exam 1 score, exam 2 score, exam
3 score, and participation score. Each field will have an
identifier denoting the field, followed by a colon, followed by
the value. An example would look as follows:
Name:Bob proj1:80 proj2:76 proj3:67 proj4:99 exam1:70 exam2:80
exam3:88 participation:100
Your program will read each line from the file, parse it to
extract the name and scores, and create a Student object
containing the name and scores for that student. As each student
object is created, it should be appended to a list that holds the
collection of student objects. Once the file has been processed,
your program will calculate the grade for each student as well as
the min, max, and average grades for the class. Finally, your
program will save the calculated information to a new text file.
Grades should be calculated as follows:
- Projects - 45% (equally weighted)
- Exams - 45% (equally weighted)
- Participation - 10%
Implementation Requirements and Hints
- Begin by mapping out the design of your program. You will
probably want to have a Student class that stores the name and
individual scores for a student and can calculate the final
grade for that student. You should also consider implementing a
Student DB class that stores the list of Student objects and can
calculate the min, max, and average grades for the entire class.
Think carefully about where the file input and output
functionality should be implemented and make sure that you can
justify all parts of your design.
- Make sure to implement and test your program in small
increments. For example, you can begin by implementing a
program that opens the file, reads in the data, and extracts and
prints the appropriate information. Next, implement the Student
and StudentDB classs. Then, merge the two pieces such that you
store the extracted data in the appropriate objects rather than
simply printing it. Finally, implement the logic to calculate
the min/max/avg.
- You should refer to the python library reference (http://docs.python.org/lib/string-methods.html)
for information about parsing strings. In particular, you will
probably need the split method.
Extra Credit Opportunity
For extra credit, allow the user to view and make changes to the
student information. You will need to implement a menu that
allows the user to select which information he/she wants to view
or change.
Due 1:30PM Monday October 23, 2006
- Complete and submit your working code. Turn in a hard copy in class and place a copy of your .py file in the submit directory /home/submit/cs110/username.
- Make sure that each function is well documented. Your documentation should specify the type and function of the input parameters and output.
- Run your program on a variety of inputs ensuring that all error conditions are handled correctly.
Note: No portion of your code may be copied from any other
source including another text book, a web page, or another
student (current or former). You must provide citations for any
sources you have used in designing and implementing your program.
Sami Rollins