Final answer:
Write a for loop to sum elements of the integer vector 'yearlyScores' until the sum 'maxSum' is >= 300 or the end of the vector is reached. The solution involves initializing 'maxSum' to zero and adding elements of 'yearlyScores' until the condition is met.
Step-by-step explanation:
The student's question involves writing a for loop in a programming context to sum elements of an integer vector. The student is tasked to sum up the integers in the vector yearlyScores until the accumulated sum, maxSum, is greater than or equal to 300, or until the end of the vector is reached. Here is a sample solution in pseudocode:
maxSum = 0
for i = 0 to vecVals - 1
maxSum = maxSum + yearlyScores[i]
if maxSum >= 300
break
end for
print "maxSum: " + maxSum
This loop iterates over each element of yearlyScores, adding each element's value to maxSum. The loop exits early if maxSum reaches or exceeds 300.