Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #include #include using namespace std; class course { public: string name;//CIS554 int section;//1 int credits;//3 string grade;//A- course() {} course(string n, int s,

#include  #include  #include  #include  using namespace std; class course { public: string name;//CIS554 int section;//1 int credits;//3 string grade;//A- course() {} course(string n, int s, int c, string g) { name = n; section = s; credits = c; grade = g; } //You might need to implement some overloaded operators here. bool operator<(const course& c) const; bool operator==(const course& c) const; float num_grade(); }; float course::num_grade() { map M{ {"A", 4.0f}, {"A-", 3.667f}, {"B+", 3.333f}, {"B", 3.0f}, {"B-" , 2.667f}, {"C+" , 2.333f}, {"C", 2.0f}, {"C-" , 1.667f}, {"D", 1.0f}, {"D-" , 0.667f}, {"F", 0.0f} }; return M[grade]; } bool course::operator<(const course& c) const { return (name < c.name); } bool course::operator==(const course& c) const { return (name == c.name); } /* * Semester numbers: Spring 2019: 20191; Fall 2019: 20192, etc. Implement the following functions. When adding a student, if the student is already in DB, then ignore the operation. When adding a course, if the course is already in DB (even if it is in a different semester, then ignore the operation. All courses in a semester should be sorted according to name (increasing order) When dropping a course, if the course does not exist, then ignore the operation. When removing a student, if the student does not exist, then ignore the operation. All courses in a semester need to be sorted. When dropping or adding a course, overall GPA, semester GPA, overall credits and semester credits all need to be updated. If after drop_course, the list becomes empty, you don't need to remove the list. */ void add_student(map*, map*, list*> >* >*> & DB, int id); void remove_student(map*, map*, list*> >* >*>& DB, int id); void add_course(map*, map*, list*> >* >*>& DB, int semester, int id, course c); //20171 Spring semester of 2017; 20172: Fall semester of 2017 void drop_course(map*, map*, list*> >* >*>& DB, int semester, int id, course c); void print_student_semester_courses(map*, map*, list*> >* >*>& DB, int semester, int id); void print_student_all_courses(map*, map*, list*> >* >*>& DB, int id); //Implement additional functions such that you can do //cout << DB << endl; //You might need to implement some overloaded operators in the course class. int main() { //map*> >*>> DB; map*, map*, list*> >* >*> DB; add_student(DB, 11111); course C1("CIS554", 1, 3, "A-"), C2("CSE674", 1, 3, "B+"), C3("MAT296", 8, 4, "A"), C4("WRT205", 5, 3, "A"); add_course(DB, 20171, 11111, C1); add_course(DB, 20171, 11111, C4); add_course(DB, 20171, 11111, C3); add_course(DB, 20171, 11111, C2); print_student_semester_courses(DB, 20171, 11111); drop_course(DB, 20171, 11111, C1); print_student_semester_courses(DB, 20171, 11111); //sorted according to course name course C5("CIS351", 2, 3, "A-"), C6("PSY205", 5, 3, "B+"), C7("MAT331", 2, 3, "A"), C8("ECN203", 4, 3, "A"); add_course(DB, 20172, 11111, C5); add_course(DB, 20172, 11111, C6); add_course(DB, 20172, 11111, C7); add_course(DB, 20172, 11111, C8); add_course(DB, 20172, 11111, C3); print_student_all_courses(DB, 11111);//ID GPA add_student(DB, 11112); add_course(DB, 20171, 11112, C2); add_course(DB, 20171, 11112, C5); add_course(DB, 20171, 11112, C7); add_course(DB, 20171, 11112, C4); print_student_semester_courses(DB, 20171, 11112); add_course(DB, 20172, 11112, C8); add_course(DB, 20172, 11112, C3); add_course(DB, 20172, 11112, C5); add_course(DB, 20172, 11112, C1); print_student_semester_courses(DB, 20172, 11112); print_student_all_courses(DB, 11112); //Overload operator<< to allow the following cout statements. cout << DB << endl; remove_student(DB, 11111); cout << DB << endl; return 0; } void add_student(map*, map*, list*> >* >*>& DB, int id) { if (DB.find(id) != DB.end()) return; DB[id] = new pair*, map*, list*> >* > { new pair{0, 0.0f}, new map*, list*> > { } }; } void remove_student(map*, map*, list*> >* >*>& DB, int id) { } void add_course(map*, map*, list*> >* >*>& DB, int semester, int id, course c) { if (DB.find(id) == DB.end()) return; if (DB[id]->second->find(semester) == DB[id]->second->end()) { { (* (DB[id]->second))[semester] = {new pair{0, 0.0f}, new list {}}; } auto& R1{ (*(DB[id]->second))[semester] }; //a pair auto& R2{ *( ( * (DB[id]->second))[semester].second) }; //a list cout << R2.size() << endl; //YOu can use R2.insert(iterator, ...); // //R2.insert( ....) // //Complete the rest. } void drop_course(map*, map*, list*> >* >*>& DB, int semester, int id, course c) { } void print_student_semester_courses(map*, map*, list*> >* >*>& DB, int semester, int id) { } void print_student_all_courses(map*, map*, list*> >* >*>& DB, int id) { } 

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

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions

Question

understand the key issues concerning international assignments

Answered: 1 week ago

Question

00 00

Answered: 1 week ago

Question

Discuss all branches of science

Answered: 1 week ago