Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void letterB (const string &input, const College &college, const unordered_map<string, vector<Course>> &map) {
- double percentage;
- string gradingType;
- cout << "letter B threshold? ";
- cin >> percentage;
- vector<Course> coursePercentages;
- // perform a department wide search
- if (!(input == "all")) {
- if (map.find(input) == map.end()) {
- cout << "**dept not found\n";
- return;
- }
- // get the courses from the department
- vector<Course> deptCourses = map.at(input);
- // retrieve the courses in the specified department
- for (auto &c: deptCourses) {
- GradeStats stats = GetGradeDistribution(c);
- // if the percent of Bs are greater than the percentage entered, add to the vector
- if (stats.PercentB > percentage) {
- coursePercentages.push_back(c);
- }
- }
- }
- // perform a college-wide search
- else if (input == "all") {
- for (auto &d: college.Depts) {
- for (auto &c: d.Courses) {
- GradeStats stats = GetGradeDistribution(c);
- if (stats.PercentB > percentage) {
- coursePercentages.push_back(c);
- }
- }
- }
- }
- // sort the B percentages vector by percentB > department > course number > section number
- sort(coursePercentages.begin(), coursePercentages.end(), [=] (Course &a, Course &b) {
- GradeStats aStats = GetGradeDistribution(a);
- GradeStats bStats = GetGradeDistribution(b);
- if ((fabs(aStats.PercentB) < fabs(bStats.PercentB) < .0001)) {
- return true;
- }
- else if ((fabs(aStats.PercentB) > fabs(bStats.PercentB) < .0001)) {
- return false;
- }
- else {
- if (a.Dept < b.Dept) {
- return true;
- }
- else if (a.Dept > b.Dept) {
- return false;
- }
- else {
- if (a.Number < b.Number) {
- return true;
- }
- else if (a.Number > b.Number) {
- return false;
- }
- else {
- if (a.Section < b.Section) {
- return true;
- }
- else {
- return false;
- }
- }
- }
- }
- });
- if (coursePercentages.empty()) {
- cout << "**none found\n";
- return;
- }
- for (auto &c: coursePercentages) {
- cout << c.Dept << " " << c.Number << " (section " << c.Section << "): " << c.Instructor << endl;
- cout << " # students: " << c.getNumStudents() << endl;
- // determine the grading type
- if (c.getGradingType() == 0) gradingType = "letter";
- else if (c.getGradingType() == 1) gradingType = "satisfactory";
- else if (c.getGradingType() == 2) gradingType = "unknown";
- cout << " course type: " << gradingType << endl;
- printDistribution(GetGradeDistribution(c));
- printDFW(c);
- }
- //printResults(coursePercentages);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement