Share
Explore BrainMass

write a program to calculate the exam grades for a class of a few hundred students

You will write a program to calculate the exam grades for a class of a few hundred students.

Input
Read the input file into your program as a comand line argument, rather than hardcoding the name as you were allowed to in project 3.

Each student has a last name, first name, and five problem scores (the four problems on the exam and one extra credit problem). Your program should scan students data in from a file and store it in an array of 27 linked lists. Students will be sorted to different lists by the first letter of their last name. So "Hunter, Johnny"
will be sorted to arr[7] list, as H is the 8th letter in the alphabet (remember 'H' - 'A' = 7). The 27th list should store any names that somehow do not start with a letter of the alphabet.

The input file itself is formatted so that each student's entry is one line. All entries are divided by single spaces, so scanning them in should be fairly easy.

You can assume that each students first and last name will consist of at most 20 characters each. I'd prefer that you allocate these strings dynamically, but it isn't a requirement.

Calculating scores
Along with the five problem scores, each student structure should also contain room for a final exam grade. This will be the sum of four of the four exam problems. If the extra credit problem has a higher score than one of the exam problems, then it can be used (only once) to replace that problem score.

So if Johnny's scores were 11, 17, 19, and 5, with an extra credit score of 8,
then his final grade would be 11 + 17+ 19 + 8 = 55 out of a total 80.

However if Sue's scores were 20, 5, 6, and 18, with an extra credit score of 10,
Then her final grade would be 20 +10 + 6 + 18 = 54 out of 80.

So the extra credit problem will replace the lowest problem score. Really much less complicated than I've made it sound.

Output
Print a menu with four options.
The first should prompt for a letter and print the names and final scores for all students whose last names begin with the input letter.

The second option should be to compute the class average.

The third option should prompt for a score number 1-6 and a number of points 0-20.
Score numbers 1-4 correspond to problems 1-4.
Score number 5 corresponds to the extra credit problem.
Score number 6 corresponds to the final grade.

The function you write for this should increment the specified score by the number of points given. Final grades will have to be recalculated in the first five cases, so that function may have to be called again.

The last option should free all allocated memory and exit.

Modification
--------------------------------------------------------------------------------------------------
First off, you can assume a fixed size of 20 characters for first and last names. I would prefer if you dynamically allocated these, but I won't require you to.

Second, I didn't specify how the program should accept its input file (theres
only one file). Do this with command line arguments, rather than hardcoding the
name

Last, expand the functionality a bit. Rather than computing the average for one letter, include a menu with four options.

The first should prompt for a letter and print the names and final scores for all students whose last names begin with the input letter.

The second option should be to compute the class average, rather than the
average for one list.

The third option should prompt for a score number 1-6 and a number of points
0-20.
Score numbers 1-4 correspond to problems 1-4.
Score number 5 corresponds to the extra credit problem.
Score number 6 corresponds to the final grade.

The function you write for this should increment the specified score by the
number of points given. Final grades will have to be recalculated in the first
four cases, so that function may have to be called again.

Attachments

Solution Preview

Please see the attached file.

Please note:
Due to a bug in the <stdio.h> installed in my Linux environment, a character ...

Solution Summary

You will write a program to calculate the exam grades for a class of a few hundred students.

$2.19