LEASE ANSWER IN C++ 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: • First name (a string, 1 word) • Last name (also a string, also 1 word) • 5 quiz scores (integers, range 0-20) • 3 exam scores (integers, range 0-100) 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.
PLEASE ANSWER IN C++
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:
• First name (a string, 1 word)
• Last name (also a string, also 1 word)
• 5 quiz scores (integers, range 0-20)
• 3 exam scores (integers, range 0-100)
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.
• First name (left justified, 20 characters)
• Last name (left justified, 20 characters)
• 5 quiz scores (each right justified in a field 4 characters wide)
• 3 exam scores (each right justified in a field 5 characters wide)
• new-line character ‘\n’ or use of endl in output function
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. 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).
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images