I am trying to get this program to ask for the student names and then do the midterm and final grades for student #1 and then the same for student #2 and so on. Right now it asks for the midterm of student #1 and then the midterm of student #2 and the same for the final grade. How do I reorder my code to get it to be in the proper order (or atleast the order I need)?

import javax.swing.JOptionPane;
public class helper {
static final int MAX = 30;
public static void main (String [] args)
{
String [] studentNames;
int [] studentMidterm;
int [] studentFinal;

int numStudents;

numStudents = howMany();

studentNames = enterNames(numStudents);
studentMidterm = enterMidterm(numStudents, studentNames);
studentFinal = enterFinal(numStudents, studentNames);

summary (studentNames, studentMidterm, studentFinal, numStudents, averageMidterm(numStudents, studentMidterm), averageFinal(numStudents, studentFinal));
}

private static int howMany()
{
int num;
do {
num = Integer.parseInt(JOptionPane.showInputDialog("How many students in the class?"));
} while (num < 1 || num > MAX);

return num;
}

private static String [] enterNames (int num)
{
String [] names = new String [MAX];
for (int i = 0; i < num; i++)
names[i] = JOptionPane.showInputDialog("Enter name of student #"+(i+1)+" : ");
return names;
}

private static int [] enterMidterm (int num, String [] names)
{
int [] scores = new int [MAX];
for (int i = 0; i < num; i++)
scores[i] = Integer.parseInt(JOptionPane.showInputDialog
("Enter Midterm Score for "+names[i]+" : "));
return scores;
}
private static int [] enterFinal (int num, String [] names)
{
int [] scores = new int [MAX];
for (int i = 0; i < num; i++)
scores[i] = Integer.parseInt(JOptionPane.showInputDialog
("Enter Final Score for "+names[i]+" : "));
return scores;
}

private static int averageMidterm (int num, int[] scores)
{
int total = 0;
for (int i = 0; i < num; i++)
total += scores[i];
return total/num;
}
private static int averageFinal (int num, int[] scores)
{
int total = 0;
for (int i = 0; i < num; i++)
total += scores[i];
return total/num;
}

private static void summary(String [] names, int [] scoresMidterm, int [] scoresFinal, int n, int avgMidterm, int avgFinal)
{
String output = "Individual Student Scores:";
for (int i =0; i < n; i++)
output += "\n "+names[i]+" "+scoresMidterm[i]+" "+scoresFinal[i];
output += "\n\nMidterm Average: "+avgMidterm + "\n\nFinal Average: " +avgFinal;
JOptionPane.showMessageDialog(null,output);
}

}