#include <iostream>
#include <vector>
#include <string>
std::string toLetterGrade(double score) {
// Define scores and grades
std::vector<double> scores = {95.0, 90.0, 85.0, 80.0, 75.0, 70.0, 65.0, 60.0};
std::vector<std::string> grades = {"A+", "A", "B+", "B", "C+", "C", "D+", "D"};
// Iterate through scores and find the grade
int scores_size = scores.size();
for (size_t i = 0; i < scores.size(); i++) {
if (score >= scores[i]) {
return grades[i];
}
}
return "F"; // Default grade if none of the scores match
}
int main() {
// Test the program with individual scores
std::cout << toLetterGrade(95) << std::endl; // A+
std::cout << toLetterGrade(90) << std::endl; // A
std::cout << toLetterGrade(80) << std::endl; // B
std::cout << toLetterGrade(60) << std::endl; // D
std::cout << toLetterGrade(50) << std::endl; // F
}
/*
run:
A+
A
B
D
F
*/