I\'m trying to use the below code to calculate the average of a set of values that a user enters and display it in a jTextArea but it does not work properly. Sa
jTextArea
Why use a clumsy for loop with an index when you have the enhanced for loop?
private double calculateAverage(List marks) { Integer sum = 0; if(!marks.isEmpty()) { for (Integer mark : marks) { sum += mark; } return sum.doubleValue() / marks.size(); } return sum; }