What I thought would be an extremely simple project has proven more difficult for me than I thought. Here are the parameters:
Quote:
Write a script to calculate the total score and assign a letter grade for each student
(source data is in the file “grades”). Output the all students’ name, scores, and grades
in descending order of the total score. Note: please save the output to the file
“finalgrades.txt”.
Format of source data file (grades.txt):
Name Exam1 Exam2 Exam3
Content of source data file (grades.txt):
Tom 23 12 15
Jack 30 15 29
Jane 31 25 19
The final letter grade will be determined based on the following criteria:
A 90 and above
B 80 thru 89
C 65 thru 79
D 50 thru 64
F less than 50
Output (finalgrades.txt)
Name Exam1 Exam2 Exam3 Total Grade
Jane 31 25 29 85 B
Jack 30 15 29 74 C
Tom 23 12 15 60 D
|
Thus far, I've been able to sort the final grades, but I'm having a lot of trouble with appending the correlating letter grade to the end of each line. Any help would be greatly appreciated. Thanks!