Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

getGrades(float scores, string grades, int size) --- convert from score to lette

ID: 3587249 • Letter: G

Question

getGrades(float scores, string grades, int size) --- convert from score to letter grade for each score. TODO

Write a function getGrades that converts an array of floats representing students' grades into strings representing their letter grades. The function does not return a value, but should fill in the grades array.

The function should take the following parameters:

an array of floats scores with entries in the range [0, 100]

an array of strings grades in which the associated grade is returned.

an integer representing the size of the array size

Use the grading criteria for this class. Assume for this exercise that ranges are inclusive on the lower end.
e.g., A is [93, 100] , A- is [90, 93), B+ is [87, 90), B is [83, 87),..., less than 60 is an F.

If the following array is provided to the function:

Explanation / Answer

#include <iostream>
using namespace std;
void getGrades(float scores[], string grades[], int size) {
for(int i=0;i<size;i++) {
if(scores[i] >= 90) {
grades[i] = "A";
} else if(scores[i] >= 80 && scores[i] < 90) {
grades[i] = "B";
} else if(scores[i] >= 70 && scores[i] < 80) {
grades[i] = "C";
} else if(scores[i] >= 60 && scores[i] < 70) {
grades[i] = "D";
}else {
grades[i] = "F";
}
}
}

int main()
{
float scores[] = {92.8, 87, 74, 94.5};
string grades[4];
getGrades(scores, grades, 4);
for(int i=0;i<4;i++) {
cout<<grades[i]<<" ";
}
cout<<endl;
return 0;
}

Output: