Agreed with others, arrays and OOP are two different and overlapping concepts. It's like saying, "How should I get to work today? On time, or in a car?" You can do both/either/neither, they are two different things.
Assuming you have one person (your friend) in the program with a set of scores, and you add all the scores up to find a grade, then just use an "array" (list, sequence, vector, etc)
C++:
vector<float> myScores;
myScores.push_back(100.0);
myScores.push_back(50.5);
myScores.push_back(10.0);
float calcGrade(vector<float> scores) {
float grade = 0;
for (unsigned int i=0; i<scores.size(); i++) {
grade += scores[i];
}
return grade / scores.size();
}
calcGrade(myScores)
Python:
scores = []
scores.append(100.0)
scores.append(50.5)
scores.append(10.0)
def calcGrade(scores):
grade = 0
for i in scores:
grade += i
return grade / len(scores)
calcGrade(scores)
However, if you have multiple people in your program with multiple scores, then you should consider using a better structure to hold data. You could do a more OOP approach
class Person {
vector<float> scores;
float calcGrade();
}
or just take it simple with multi-dimensional arrays. But at that point, you probably need some "OOP" in your program.