The code snippet below has accessing global variable side affect, how can I improve this code snippet?
double total = 0;
for (Student s : myStudentList){
total = total + s.getSchScore();
}
System.out.println(total + " is total marks.");