Somebody please help with this class #include <iostream> #include <iomanip> #inc
ID: 3555136 • Letter: S
Question
Somebody please help with this class
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
#include "class_TRANSCRIPT.h"
class TRANSCRIPT
{
public:
TRANSCRIPT();
// Return #courses in transcript.
int NumCourses();
// Add new course to transcript.
void AddNewCourse();
// Calculate GPA based on credit hours and grades for courses.
float GPA();
// List all courses with specified grade.
void CoursesByGrade(char LetterGrade);
// Remove course from transcript.
void RemoveCourse(string coursename);
// Calculate cumulative credit hours earned.
void CumHours();
// List passed courses (D or higher).
void ListPassedCourses(ostream &);
// List failed courses (below D).
void ListFailedCourses(ostream &);
// Count passed courses (lowpass or higher
int numPassedCourses(char lowpass);
).
int numFailedCourses(); // Count failed courses.
private:
COURSE * CourseList;
int courseCount;
}; //class TRANSCRIPT
Explanation / Answer
I am not providing answer just giving an old code i have may be it is useful to you
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
class Student {
vector<string> _Courses;
string _name;
public:
Student(string name) : _name(name) {}
void addCourse(string name) {
_Courses.push_back(name);
}
int getNumberOfCourses() {
return _Courses.size();
}
string getName() {
return _name;
}
void printTranscript() {
cout << _name << "'s Transcript" << endl;
cout << "Number of courses: " << _Courses.size() << endl;
cout << "Courses: ";
for (string &courseName : _Courses) {
cout << courseName << " ";
}
cout << endl << endl;
}
};
class University {
vector<Student> _Students;
public:
Student & addStudent(string name) {
// Add the student to the end of the vector.
_Students.push_back(Student(name));
// Return the Student object just added to the vector as a reference.
return _Students.back();
}
void printRegistrar() {
cout << "University Registrar" << endl;
cout << left << setw(10) << "Name" << setw(10) << "Courses" << endl;
for (Student & student : _Students) {
cout << setw(10) << student.getName() << setw(10) << student.getNumberOfCourses() << endl;
}
}
};
int main(int argc, char** argv) {
// Create a new university called UHD.
University UHD;
// Add 4 students to UHD.
UHD.addStudent("Jim");
UHD.addStudent("Bill");
Student Bob = UHD.addStudent("Bob");
UHD.addStudent("Greg");
// Add 3 classes for Bob
Bob.addCourse("WRTG140");
Bob.addCourse("MATH009");
Bob.addCourse("BIOL101");
// Shows Bob correctly has 3 classes.
Bob.printTranscript();
// BUG: Shows Bob incorrectly has 0 classes.
UHD.printRegistrar();
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.