Guest User

Untitled

a guest
Nov 21st, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. package chapter5.section2;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. class ScoreAverage {
  7. private List<Double> scoreData = new ArrayList<>();
  8.  
  9. double scoreAverage() {
  10. double sum = 0;
  11. for (Double score : scoreData) {
  12. sum += score;
  13. }
  14. return sum / scoreData.size();
  15. }
  16.  
  17. boolean add(Double score) {
  18. return scoreData.add(score);
  19. }
  20.  
  21. int size() {
  22. return scoreData.size();
  23. }
  24.  
  25. }
Add Comment
Please, Sign In to add comment