I have tried to get the standard deviation, but it doesn't work.

int[]scores = {
  52, 69, 85, 98, 95, 76, 82, 83, 92, 87, 94, 68, 77, 45, 70, 71, 59, 60, 74, 84, 83, 73, 75, 78, 80, 92, 91, 97, 62, 84
};

void standardDeviation() {
  float average;
  for (int x=0; x<scores.length; x++) {
    float total = 0;
    for (int i=0; i<scores.length; i++) {
      total += scores[i];
    }
    noLoop();
    float stdDeviation=0;
    average=total/scores.length;
    float differences = (scores[x]-average);
    float squaredDifferences= differences*differences;
    float variance=squaredDifferences/scores.length;
    stdDeviation=+ sqrt(variance);
    textFont(createFont("consolas", 20));
    text("Standard Deviation: "+ stdDeviation, 20, 170);
    println(stdDeviation);
    noLoop();
  }
}

First look at what is inside each loop and decide whether it belongs inside or outside the loop. Eg: how many times do you want to print out the standard deviation? How many times do you need to calcuiate the total?
Second: what is noLoop()?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.