Hello all. I'm about at new as you get to this part of the internet. I'm fairly new to java so forgive me if I ask some very lame questions. The program I'm building takes in 8 scores given by judges, calculates the lowest and highest scores, and then adds all the scores together minus the min and max. At the bottom of my code, commented out, is an example of what it SHOULD look like.
//packages to import
import java.io.*;
import java.util.*;
import java.text.DecimalFormat;
public class Judges
{
public static void main(String args[])
{
//declare variables
double [] input = new double[8];
Scanner scan = new Scanner(System.in);
int count = 1;
boolean done = false;
while(!done)
{
for (int i = 0; i < 8; i++)
{
try
{
//ask the user for the scores, count is added one each time this completes or the error is fixed
System.out.print("Enter Score # " + count + " : ");
input[i] = scan.nextDouble();
if(input[i] < 1.0 || input[i] > 10) throw new InputMismatchException();
else done = true;
}
catch (InputMismatchException e)
{
System.out.print("That was not a valid score\nEnter Score # " + count + " : ");
scan.next();
}//end catch
count++;
}//end for
}//end while
//call to function below
calcScore(input);
}//end main()
public static void calcScore(double[] d)
{
//initialize all scores to 0;
double totalScore = 0.0;
double minScore = 0.0;
double maxScore = 0.0;
for (int i = 0; i < d.length; i++)
{
maxScore = Math.max(maxScore, d);
minScore = Math.min(minScore, d[i]);
totalScore = totalScore + d[i];
}//end for
totalScore = totalScore - (maxScore + minScore);
//this is where the problem is, at least I think.
//The max score is being computed fine, but min score
//is always being defaulted to 0. Perhaps I'm using
//Math.min wrong? I checked to be sure all the input
//is going into the array, I just can't get minScore
//to read the actual minimum score. This is inturn
//fouling up the totalScore.
System.out.println("The maximum score is " + maxScore);
System.out.println("The minimum score is " + minScore);
System.out.println("The total score is " + totalScore);
}//end scoreClac()
//Sample of what ouput SHOULD look like:
//Enter Score # 1: 9.2
//Enter score # 2: 9.3
//Enter score # 3: 9.0
//Enter score # 4: 9.9
//Enter score # 5: 9.5
//Enter score # 6: 9.5
//Enter score # 7: 9.6
//Enter score # 8: 9.8
//The maximum score is 9.9
//The minimum score is 9.0
//The total score is 56.9
}//end classSo this is pretty much driving me up a wall, as does most programming. I'm probably overlooking something very stupid here, but I just can't see it. Can anyone help out?