Fill This Form To Receive Instant Help
Homework answers / question archive / CS 201R Fall 2020 Program 4 For this program you’ll write a simple class and use it in a vector
CS 201R
Fall 2020
Program 4
For this program you’ll write a simple class and use it in a vector.
Begin by writing a Student class. The public section has the following methods:
Student::Student()
Constructor. Initializes all data elements: name to empty string(s), numeric variables to 0.
bool Student::ReadData(istream& in)
Data input. The istream should already be open. Reads the following data, in this order:
Assumes that all data is separated by whitespace. The method returns true if reading all data was successful, otherwise returns false. Does not need to validate or range-check data; if one of the quiz or exam scores is out of range, just keep going.
bool Student::WriteData(ostream& out) const
Output function. Writes data in the following format. Each student’s data is on one line.
Note that this is a const method; it should not modify any of the object’s data. Returns true if the attempt to send the data to the stream was successful, false otherwise.
string Student::GetFirstName() const; string Student::GetLastName() const;
Accessor methods, also known as ‘getters.’ Returns data from inside the function.
float Student::CourseAverage() const
Returns the student’s weighted average as a percentage (float in range 0-100). The quiz scores are averaged together (20-point scale) and are 35% of the course grade. The exams are averaged together and are 65% of the course grade. This does not modify any of the object’s data.
bool Student::DisplayCourseAverage(ostream& out) const
Prints the student’s course average to the provided output stream, rounded to 3 decimal places. Returns true if the attempt was successful, false otherwise.
string Student::LetterGrade() const
Returns a string with the student’s letter grade, using the same grading scale as this course.
The class should assume that any input or output streams passed to public methods are already open.
The main program is quite simple. You are provided a data file with data for some number of students. Read the data into a vector. (Hint: Declare one student. Read that student’s data, then add it to the vector. Repeat.) It should then print a roster, showing the name, course average to 3 decimal places, and letter grade for each student in the course. This list should be sorted by student name (sort by last name, break ties using first name; display in usual first-name last-name order).
Results for the provided data file are shown. Your program will be tested against another data file with the same format.