Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. /**
  2. Calculates a given score, calculates the sum, and then the average of the score.
  3. */
  4.  
  5. public class DataSet
  6. {
  7.  
  8. private int numberOfInteger;
  9. private int sum;
  10.  
  11. // Comes up with the number of integer of the score and the sum of the score.
  12. public void addValue(int x)
  13. {
  14. numberOfInteger = numberOfInteger;
  15. sum = sum + x;
  16. }
  17.  
  18. // Returns the sum so it could be used.
  19. public int getSum()
  20. {
  21. return sum;
  22. }
  23.  
  24. // Return the average so it could be used.
  25. public double getAverage()
  26. {
  27. double average = sum/ numberOfInteger;
  28. return average;
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement