So in this program, which is a grading program, I am trying to compare all the students averages to find who has the highest one and list the grades and the student's names from least to greatest. Yes, I see there are other problems in the program but it is nowhere near finished.


 
 
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		String[] studentName = new String[20];
		int[] studentAverage = new int[20];
		Scanner input = new Scanner(System.in);
		int numberOf = 0;
		int sub = 0;
		int x = 0;
		int[] answers;
		int[] correct;
		int whichStudent = 0;
		int timesRan = 0;
		String AvToOr, letterGrade, stuNameAsk, goOn;
		while (x == 0) {
			whichStudent = sub;
 
			System.out
					.println("Enter student name. (Current limit of amount of students is 20.)");
			stuNameAsk = input.next();
			studentName[sub] = stuNameAsk;
 
			System.out
					.println("How many questions would you like to ask? (Maximum is infinite.)");
			int num = input.nextInt(); // get the number of times to ask
			answers = new int[num]; // student's answers
			correct = new int[num]; // for teachers
			for (int x1 = 0; x1 < num; x1++) {
				System.out.println("Enter the answer for question number: "
						+ (x1 + 1) + ".");
				correct[x1] = input.nextInt();
			}
			System.out.println("Now for the students.");
			for (int x1 = 0; x1 < num; x1++) {
				System.out
						.println("Enter the student answer for question number:"
								+ (x1 + 1));
				answers[x1] = input.nextInt();
			}
			int average = 0; // his/her grade
			for (int x1 = 0; x1 < num; x1++)
				if (correct[x1] == answers[x1])
					average++;
 
			average = (int) (((double) average) / ((double) num) * 100);
			if (average >= 90 && average <= 100) {
				letterGrade = "A";
 
			} else if (average >= 80 && average <= 89) {
				letterGrade = "B";
			} else if (average >= 70 && average <= 79) {
				letterGrade = "C";
			} else if (average >= 60 && average <= 69) {
				letterGrade = "D";
			} else {
				letterGrade = "F";
			}
			studentAverage[sub] = average;
			System.out.println(studentName[0 + whichStudent] + "'s grade is "
					+ studentAverage[0 + whichStudent] + "%");
			System.out
					.println("Do you want to enter another student? Type Y for yes and N for no.");
			goOn = input.next();
 
			if (goOn.equalsIgnoreCase("n")) {
				x++;
 
			} else if (goOn.equalsIgnoreCase("y")) {
				sub++;
				timesRan++;
 
			} else {
				System.out
						.println("Your answer is not valid. Please try again.");
				System.out.println("Do you want to enter another student?");
				goOn = input.next();
 
				if (goOn.equalsIgnoreCase("n")) {
					x++;
 
				} else if (goOn.equalsIgnoreCase("y")) {
					sub++;
					timesRan++;
 
				} else {
					System.out
							.println("Your answer is not valid. Program restarted.");
				}
			}
		}
		System.out.println("All entered students and their averages:");
		for (int varTest = 0; varTest <= timesRan; varTest++) {
			System.out.println(studentName[varTest] + "'s average is "
					+ studentAverage[varTest] + "%");
		}
Here is the specific place in which I'm trying to put the grades in order from highest to lowest...
		System.out
				.println("Would you like to (A)verage, put in (or)der from highest grade to lowest grade, or (end) the program? (Case does not matter)");
		AvToOr = input.next();
 
		 if	 (AvToOr.equalsIgnoreCase("A")){
			for (int varTest = 0; varTest <= timesRan; varTest++){
				//System.out.println(studentAverage[varTest] + studentAverage[varTest-1]);
			}
 
			}
		 else if (AvToOr.equalsIgnoreCase("top")){
				System.out.println("Test");
		}
		 else if (AvToOr.equalsIgnoreCase("or")){
			 System.out.println("test");
		 }
		 else if (AvToOr.equalsIgnoreCase("end")){
 
		 }
 
	}
}
Thanks