0

I am doing an assignment that requires me to create a GUI for input of scores. I have to then take those scores, remove the MIN and MAX value and average the scores. How do I find the MIN and MAX scores and then remove them from the array?

            iaRun1[0] = Integer.parseInt(judgeOneRunOne.getText());
            iaRun1[1] = Integer.parseInt(judgeTwoRunOne.getText());
            iaRun1[2] = Integer.parseInt(judgeThreeRunOne.getText());
            iaRun1[3] = Integer.parseInt(judgeFourRunOne.getText());
            iaRun1[4] = Integer.parseInt(judgeFiveRunOne.getText());
            iaRun1[5] = Integer.parseInt(judgeSixRunOne.getText());
            iaRun2[0] = Integer.parseInt(judgeOneRunTwo.getText());
            iaRun2[1] = Integer.parseInt(judgeTwoRunTwo.getText());
            iaRun2[2] = Integer.parseInt(judgeThreeRunTwo.getText());
            iaRun2[3] = Integer.parseInt(judgeFourRunTwo.getText());
            iaRun2[4] = Integer.parseInt(judgeFiveRunTwo.getText());
            iaRun2[5] = Integer.parseInt(judgeSixRunTwo.getText());

    //How do I get MIN and MAX values and delete them?

    // The average for run 1
    for (int i = 0; i < iaRun1.size(); i++) {
        dTotal1 += iaRun1.get(i);
        dAvg1 = dTotal1 / iaRun1.size();
    }


    // The average for run 2
    for (int j = 0; j < iaRun2.size(); j++) {
        dTotal2 += iaRun2.get(j);
        dAvg2 = dTotal2 / iaRun2.size();
    }
6
  • Sort the array, remove the first and last elements, you could use Arrays.copyOfRange to trim of the first and last elements Commented Oct 16, 2015 at 4:42
  • So how do I sort the array? With collections? Commented Oct 16, 2015 at 4:46
  • You can use Collections, but Arrays has a sort method as well. It depends if you're allowed to use Collections or not (which are more flexible) Commented Oct 16, 2015 at 4:47
  • Is it as simple as; iaRun1.sort(); Commented Oct 16, 2015 at 4:50
  • Arrays.sort(iaRun1) Commented Oct 16, 2015 at 4:50

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.