Question: Please fix my code in C++ below, I cant get it to compile. Please fix it to have a functioning output. #include #ifndef COURSE_H #define

Please fix my code in C++ below, I cant get it to compile. Please fix it to have a functioning output.

#include #ifndef COURSE_H #define COURSE_H

class Course { private: std::string stdID; int units; char grade;

public: Course(); Course(std::string stdID, int units, char grade); void set_Units(int units); void set_Grade(char grade); std::string getID() const; int get_Units() const; char get_Grade() const; int get_GP() const; }; #endif

#include #include "Course.h"

Course::Course(): stdID(""), units(0), grade(' ') {}

Course::Course(std::string stdID, int units, char grade) : stdID(stdID), units(units), grade(grade) { grade = toupper(grade); } void Course:: set_Units(int units){ this->units = units; }

void Course:: set_Grade(char grade){ this->grade = toupper(grade); } std::string Course:: getID() const{ return stdID; }

int Course:: get_Units() const{ return units; }

char Course:: get_Grade() const{ return grade; } int Course:: get_GP() const{ if(grade == 'A') return units * 4; else if(grade == 'B') return units * 3; else if(grade == 'C') return units * 2; else if(grade == 'D') return units; return 0; }

#include #include "Course.h" #ifndef STUDENT_H #define STUDENT_H

class Student { private: std::string stdName; int studentID; std::vector courses; static int NextID;

public: Student(); Student(std::string stdName); void set_Name(std::string stdName); std::string get_Name() const; int get_StudentID() const; void add_Courses(std::string stdID, int units, char grade); bool has_Courses() const; double get_GPA() const; void print_Transcript() const; }; #endif

#include #include #include #include "student.h" #include "course.h"

using namespace std;

int find_Std(vector students, int stdID) { for (int i = 0; i < students.size(); i++) { if (students[i].get_StudentID() == stdID) { return i; } } return -1; }

int main() { int choice; vector students; string stdName, courseID; int units, stdID, index; char grade; do { cout << "MAIN MENU" <> choice; if(choice == 1) { cout << "Enter name: "; cin.ignore(100, ' '); getline(cin, stdName);

students.push_back(Student(stdName)); cout << stdName << " you are registered! Student number is " << students[students.size()-1].get_StudentID() << endl; cout << " "; } else if(choice == 2) { cout << "Enter ID: "; cin >> stdID;

index = find_Std(students, stdID);

if(index == -1) { cout << "Sorry, " << stdID << " is not a valid student ID" << " " <> choice;

if(choice == 1) { cout << "Course ID? "; cin >> courseID; cout << "Units? "; cin >> units; cout << "Grade? "; cin >> grade;

students[index].add_Courses(courseID, units, grade); cout << " " << courseID << " added" << endl; cout << " "; } else if(choice == 2) { cout << "Your GPA is " << fixed << setprecision(2) << students[index].get_GPA() << endl; cout << " "; } else if(choice == 3) { students[index].print_Transcript(); cout << " "; } } while(choice != 4); } } } while(choice != 3);

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!