Jump to content

svegori1950

Member
  • Posts

    14
  • Joined

  • Last visited

Reputation Activity

  1. Informative
    svegori1950 got a reaction from Hip in Java: Summing values of Arrays and Dividing them to get the average in a for-loop   
    You calculate average and return it at the "durchschnitt" method (which I renamed here to "erhaltenDurchschnitt") like this:
    public static double erhaltenDurchschnitt(double[] d) { double sum = 0; for(int i = 0; i < d.length; i++) { sum += d[i]; } return sum / d.length; } Then at the end of the "main" method you add:
    JOptionPane.showMessageDialog(frame, "Der Durchschnitt betragt " + erhaltenDurchschnitt(durchschnitt)); System.exit(0);  
×