Ok so this is a grading program. I have it so the user can input 2 students and then at the end using an if statement it is suppose to compare them and print out who had the higher grade. Seems simple but it never runs the line of code to print out whos grade is higher:

Here is the Main class:

Here is the students class to run a second studentimport java.util.Scanner; public class Main2 { int stuAverage; static String student; public static void main(String[] args) { Scanner input = new Scanner(System.in); Students stu2 = new Students(); String grade; int[] answers; int[] correct; System.out.println("Enter student's name."); student = input.next(); System.out.println(); System.out.println("How many questions would you like to ask?"); 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 x = 0; x < num; x++) { System.out.println("Enter the answer for question number: " + (x + 1) + "."); correct[x] = input.nextInt(); } System.out.println("Now for the students."); for (int x = 0; x < num; x++) { System.out.println("Enter the student answer."); answers[x] = input.nextInt(); } int average = 0; // his/her grade for (int x = 0; x < num; x++){ if (correct[x] == answers[x]){ average++; } } average = (int) (((double) average) / ((double) num) * 100); if (average >= 90 && average <= 100) grade = "A"; else if (average >= 80 && average <= 89) grade = "B"; else if (average >= 70 && average <= 79) grade = "C"; else if (average >= 60 && average <= 69) grade = "D"; else grade = "F"; int stuAverage; stuAverage = average; stu2.forMutipleStu(); } }

Thanks!import java.util.Scanner; public class Students extends Main2 { public void forMutipleStu(){ Scanner input = new Scanner(System.in); String grade2; int [] answers2; int[] correct2; String student2; System.out.println("Enter student's name."); student2 = input.next(); System.out.println("A=1, B=2, C=3, D=4"); System.out.println("How many questions would you like to ask?"); int num2 = input.nextInt(); // get the number of times to ask answers2 = new int[num2]; // student's answers correct2 = new int[num2]; // for teachers for (int x = 0; x < num2; x++){ System.out.println("Enter the answer for question number: " + (x+1) + "."); correct2 [x] = input.nextInt(); } System.out.println("Now for the students."); for (int x = 0; x < num2; x++){ System.out.println("Enter the student answer."); answers2[x] = input.nextInt(); } int average2 = 0; // his/her grade for (int x = 0; x < num2; x++){ if (correct2[x] == answers2[x]){ average2++; } } average2 = (int) (((double)average2)/ ((double)num2) * 100); if (average2 >= 90 && average2 <= 100) grade2 = "A"; else if (average2 >= 80 && average2 <= 89) grade2 = "B"; else if (average2 >= 70 && average2 <= 79) grade2 = "C"; else if (average2 >= 60 && average2 <= 69) grade2 = "D"; else grade2 = "F"; int stuAverage2; stuAverage2 = average2; if (stuAverage > stuAverage2 ){ System.out.println(student + " has the highest grade of all students entered!"); } else if (stuAverage2> stuAverage){ System.out.println(student2 + " has the highest grade of all students entered!!"); } } }