#include #include #include #include // Round down all provided student scores. std::vector round_down_scores(std::vector student_scores) { return std::vector(student_scores.begin(), student_scores.end()); } // Count the number of failing students out of the group provided. int count_failed_students(std::vector student_scores) { int count{0}; for (auto score : student_scores) { if (score <= 40) count++; } return count; } // Determine how many of the provided student scores were 'the best' based on // the provided threshold. std::vector above_threshold(std::vector student_scores, int threshold) { std::vector res; for (auto score : student_scores) { if (score >= threshold) res.emplace_back(score); } return res; } // Create a list of grade thresholds based on the provided highest grade. std::array letter_grades(int highest_score) { int step{(highest_score - 40) / 4}; std::array grades{41, 0, 0, 0}; for (int i{1}; i < 4; ++i) { grades[i] += grades[i - 1] + step; } return grades; } // Organize the student's rank, name, and grade information in ascending order. std::vector student_ranking(std::vector student_scores, std::vector student_names) { std::vector res; int len = student_scores.size(); for (int i{0}; i < len; i++) { res.emplace_back(std::to_string(i + 1) + "." + " " + student_names[i] + ": " + std::to_string(student_scores[i])); } return res; } // Create a string that contains the name of the first student to make a perfect // score on the exam. std::string perfect_score(std::vector student_scores, std::vector student_names) { int len = student_scores.size(); for (int i{0}; i < len; i++) { if (student_scores[i] == 100) { return student_names[i]; } } return ""; }