The directions alone are a little overwhelming for me. I\'m in beginner CS class
ID: 3634202 • Letter: T
Question
The directions alone are a little overwhelming for me. I'm in beginner CS class and for our final project we're suppose to do the following: (Any help is really appreciated bits of code, guidelines, tutorials, etc...)Write a grading program for a course with the following grading policies:
1. Each student submits a variable number of homework assignments, each graded on the basis of 100 points. The lowest homework assignment should be thrown out and the remaining homework assignments should be averaged to obtain the homework grade.
2. There are two midterm exams and a final exam, each graded on the basis of 100 points
3. The final exam counts for 40% of the grade, each of the midterms counts for 20% of the grade, and the average homework grade counts for 20% of the grade. For example, suppose the student completed 5 homework assignments with grades of 80, 70, 75, 85, and 90. The student scored 100 and 95 on the midterms and a 90 on the final. The lowest homework assignment of 70 is thrown out, and hence the weighted score is computed as:
weighted_avg = .2 * (80+75+85+90)/4 + .2 * 100 + .2 * 95 + .4 * 90
Any grade of 90 or more is an A, any grade of 80 or more (but less than 90) is a B, any grade of 70 or more (but less than 80) is a C, any grade of 60 or more (but less than 70) is a D, and any grade below 60 is an F.
Format of the Input and Output
The program will read grades from an input file. Grades have the format:
firstname lastname type grade
where type is a character code denoting the type of assessment. ‘h’ represents a homework grade, ‘m’ represents a midterm, and ‘f’ represents a final. For example:
Minnie Mouse h 88
Bugs Bunny h 53
Bugs Bunny h 57
Mary Yarbough f 90
Wily Coyote f 52
Sean Yarbough h 75
Smiley Lab m 93
Minnie Mouse h 95
Mary Yarbough h 63
Wily Coyote m 43
Bugs Bunny f 83
…
Your program should prompt the user for the name of the grade file. It will then read all of the student grades into a set of student objects, compute each student’s weighted average, sort the students into descending order by weighted average using selection sort, and finally print the students in descending order by weighted average using the format:
firstname lastname weighted_avg letter_grade
The output should be formatted as follows:
1. firstname: left justified in a field 10 characters wide
2. lastname: left justified in a field 15 characters wide
3. weighted_avg: right justified in a field 5 characters wide with 1 decimal place
4. letter_grade: a one character wide field
There should be a single blank space between each field. For the sample grades.txt input file, the output should be:
Minnie Mouse 96.9 A
Smiley Lab 91.7 A
Mary Yarbough 89.3 B
Sean Yarbough 79.5 C
Bugs Bunny 67.9 D
Wily Coyote 46.4 F
Classes
Make each student record be a class, The class should have member variables for each of the inputs described above. You will probably need an additional member variable to keep track of how many midterm scores have been entered thus far. The class should use an array of ints to keep track of the midterms, since their number is known in advance. It should use a vector of ints to keep track of homework assignments, since each student may complete a different number of homeworks assignments and you have not been given an upper bound on the number of assignments.
There should be accessor methods for returning the firstname, lastname, weighted average, and letter grade. You can choose whether to explicitly store the weighted average and letter grade, or whether to calculate them when requested. Should you decide to explicitly store them, you will probably want to define an additional member function that computes the weighted average and letter grade for a student and then call this method for each student once all the input has been read from the grades file. The calculation of a student’s weighted average should not lose precision due to integer arithmetic (i.e., you want to do floating point division to obtain the homework average, not integer division).
There should be mutator methods for setting the final exam score, the first and last names, and for adding midterm and homework scores. Finally there should be a constructor that takes two parameters, a student’s first and last name, and initializes the appropriate member variables to these names. The constructor should also initialize the final exam field to 0.
Make all member variables be private and all member functions be public. Here is a template for your class declaration:
class Student {
public:
Student(string fname, string lname);
string getFirstName();
string getLastName();
double getWeightedAvg();
char getLetterGrade();
void calculateAvgAndGrade(); // optional
void setFinal(int score);
void setFirstName(string name);
void setLastName(string name);
void addMidterm(int score);
void addHomework(int score);
private:
// your member variables
};
You need to complete the template by filling in the declarations for your member variables. Then you need to write the function definitions for each of the member functions.
Reading the Input into Student Records
When you read a grade, you will first need to determine whether or not a record already exists for that student. I suggest you use a vector of students to store student objects. Each time you read a line from the grade file, do a sequential search for that student. If the student does not exist, then add a new student object for that student to the vector. Once a student record is added, you can start adding information to the record. When you have read all the grades, you can pass your student vector to your selection sort routine for sorting.
Pointers
For maximum credit, dynamically allocate student objects when you need new ones, and use pointers to refer to the student objects. For a 5 point deduction, you can declare a single student object in main, use its mutator functions to set the firstname and lastname fields when you have a new student, and then append this object to the vector. C++ will actually append a copy of the student object to the vector, rather than the object itself.
Explanation / Answer
I am getting run time errors i left it out cant help you sorry