Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ format, only Registrar.h and Registrar.cpp //TO BE COMPLETED sections need to be complete. main.cpp below does not need to be changed. /// Registrar.h

In C++ format, only Registrar.h and Registrar.cpp "//TO BE COMPLETED" sections need to be complete. main.cpp below does not need to be changed.

image text in transcribedimage text in transcribed

/// Registrar.h - NEEDS COMPLETION ///

#include

#include

#include "Student.h"

using namespace std;

class Registrar {

public:

void readTextfile(string filename); // Load information from a text file with the given filename: THIS IS COMPLETE

void addLine(string courseName, string cwid, char grade); // process a line from the text file

Student& getStudent(string cwid) const; // return the Student object corresponding to a given CWID

// getStudent must throw an exception if cwid is invalid

// add constructors, destructors, assignment operators if needed

private:

// Add private member variables for your class along with any

// other variables required to implement the public member functions

// TO BE COMPLETED

};

/// Registrar.cpp - NEEDS COMPLETION ///

#include

#include

#include

#include

#include "Registrar.h"

using namespace std;

// Load information from a text file with the given filename

// THIS FUNCTION IS COMPLETE

void Registrar::readTextfile(string filename) {

ifstream myfile(filename);

if (myfile.is_open()) {

cout

string courseName;

string cwid;

char grade;

while (myfile >> courseName >> cwid >> grade) {

// cout

addLine(courseName, cwid, grade);

}

myfile.close();

}

else

throw invalid_argument("Could not open file " + filename);

}

// return Student object corresponding to a given CWID

// getStudent must throw an exception if cwid is invalid

Student& Registrar::getStudent(string cwid) const {

// TO BE COMPLETED

}

// process a line from the text file

void Registrar::addLine(string courseName, string cwid, char grade) {

// TO BE COMPLETED

}

/// main.cpp - DOES NOT NEED COMPLETION ///

////////////////////////////////////////////////////////////////////////////////////////////// DO NOT EDIT THIS FILE (except for your own testing) //////////////////////////////////////////////////////////////////////////////////////////////

#include #include #include #include

#include "Student.h"

using namespace std;

template bool testAnswer(const string &nameOfTest, const T &received, const T &expected);

template bool testAnswerEpsilon(const string &nameOfTest, const T &received, const T &expected);

int main() { { // test only the Student class Student student("123456789"); testAnswer("Student::getCWID test", student.getCWID(), string("123456789")); student.addCourseGrade("cs101", 'A'); testAnswerEpsilon("Student::getGPA test1", student.getGPA(), 4.0); student.addCourseGrade("cs201", 'C'); testAnswerEpsilon("Student::getGPA test2", student.getGPA(), 3.0); }

}

template bool testAnswer(const string &nameOfTest, const T &received, const T &expected) { if (received == expected) { cout

template bool testAnswerEpsilon(const string &nameOfTest, const T &received, const T &expected) { const double epsilon = 0.0001; if ((received - expected Obiective The grades of all students are in a text file in the following format: CS121 CS121 CS121 CS121 CS253 CS253 CS253 CS131 CS131 CS131 267893043 A 454454651 B 279750343 C 546208080 C 454454651 B 279750343B 546208080 A 656529993 D 546208080 B 279750343 B where column 1 is the course name, Column 2 is the student's CWID, and column 3 is the grade You are given partial implementations of two classes. Class student stores the course information for one student - his/her list of courses and grades in each. A method in this class can then calculate the GPA. A Registrar object stores multiple students' information. It reads a text file (formatted as above) and populates objects of class Student each time a line is read. You are to complete the implementations of these two classes, adding public/private member variables and functions as needed. Your code is tested in the provided main.cpp. Initially, the given code does not even compile. As you complete the code, it should pass the tests in the main. Requirements You should not use any of the C++ Standard Library containers (such as std::array, std::vector, std::list) for this project . The text file can be large there can be upto 50,000 students. Hence, the file must be read only once (i.e., only Registrar::readTextfile must read the file and store the data in some Obiective The grades of all students are in a text file in the following format: CS121 CS121 CS121 CS121 CS253 CS253 CS253 CS131 CS131 CS131 267893043 A 454454651 B 279750343 C 546208080 C 454454651 B 279750343B 546208080 A 656529993 D 546208080 B 279750343 B where column 1 is the course name, Column 2 is the student's CWID, and column 3 is the grade You are given partial implementations of two classes. Class student stores the course information for one student - his/her list of courses and grades in each. A method in this class can then calculate the GPA. A Registrar object stores multiple students' information. It reads a text file (formatted as above) and populates objects of class Student each time a line is read. You are to complete the implementations of these two classes, adding public/private member variables and functions as needed. Your code is tested in the provided main.cpp. Initially, the given code does not even compile. As you complete the code, it should pass the tests in the main. Requirements You should not use any of the C++ Standard Library containers (such as std::array, std::vector, std::list) for this project . The text file can be large there can be upto 50,000 students. Hence, the file must be read only once (i.e., only Registrar::readTextfile must read the file and store the data in some

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions