Whenever I ask the user to input some values, it seems to take in two values per request. One set is used for the calculations of total, average, posCount, etc.... while the second set of value seems to be used to signify the end of input with a negative number. I cannot find where in my code the program is requiring two sets of values.
public class Test { public static void main(String [] args){ Scanner input = new Scanner(System.in); double[] scoreArray = new double[10]; double total = 0; int count = 0; double average = 0; for(int i = 0; i < scoreArray.length; i++){ System.out.print("Enter a new score: "); scoreArray[i] = input.nextDouble(); if(scoreArray[i] >= 0){ count++; total += scoreArray[i]; } if(input.nextDouble() < 0){ break; } } average = total / count; int posCount = 0; int negCount = 0; for(int j = 0; j < count-1; j++){ if(scoreArray[j] >= average){ posCount++; } else{ negCount++; } } System.out.println("The total is " + total); System.out.println("The total count is " + count); System.out.println("The average is " + average); System.out.println("There are " + posCount + " number(s) equal to or above the average."); System.out.println("There are " + negCount + " number(s) less than the average."); } }