Beginner Java programmer here. I am trying to make a program that asks the user how many grades they would like to enter. Then, I want to store the grades the user entered into an array. Finally, I want to find the mean of the grades entered and print out a list of every grade below the mean. As of now, my code calculates the mean of the grades that the user enters but I cannot figure out how to print the grades below the mean. I believe the problem lies in my last for loop but I cannot figure out how to fix it. Also, did I implement the array correctly? Thanks to every who took the time to help me!
public static void grades() {
int q = 0;
double grades = 0;
double total = 0;
Scanner in = new Scanner(System.in);
// user input how many grades user would like to enter
System.out.println("How many grades would you like to enter? ");
q = in.nextInt();
// user enters # of grades they requested to enter
for (int counter = 0; counter < q; counter++) {
System.out.println("Enter your grades: ");
grades = in.nextInt();
// This creates an array that stores the grades the user entered
double[] scores = new double[] {grades};
// adds up all elements (grades)
for (int k = 0; k < scores.length; k++) {
total += scores[k]; //sums up entered grades
}
}
total = total / q; //calcs mean
//loops prints grades less than mean
for (grades = 0; grades < total; grades++){
System.out.println(grades);
}
}