for some reason the if else statements related to major and credits wont work correctly. I get the first if statement for major to work but the second does not.

package students; import javax.swing.JOptionPane; public class Students { public static void main(String[] args) { //first list the integers and strings which are //the student’s major (CIS or Math) //The student’s last name //The number of credits the student has completed //The gpa //The tuition paid int tuition, finish = 1, students=0, credits, major, credits1 = 0, credits2 = 0, credits3 = 0, credits4 = 0; String smajor, last, sgpa, stuition, sfinish, scredits; double largestg = 0, largestm1 = 0, largestm2 = 0, gpa, totalgpa=0, totaltuition=0; String highnameg = "", highnamem1 = "", highnamem2 = ""; int totalcredits=0; while (finish != 0) { students=students+1; smajor = JOptionPane.showInputDialog(null, "Enter students major (1 for math 2 for cis)", "Input Data", JOptionPane.QUESTION_MESSAGE); last = JOptionPane.showInputDialog(null, "Enter students last name", "Input Data", JOptionPane.QUESTION_MESSAGE); scredits = JOptionPane.showInputDialog(null, "Enter students total amount of credits", "Input Data", JOptionPane.QUESTION_MESSAGE); sgpa = JOptionPane.showInputDialog(null, "Enter students GPA", "Input Data", JOptionPane.QUESTION_MESSAGE); stuition = JOptionPane.showInputDialog(null, "Enter students tuition paid", "Input Data", JOptionPane.QUESTION_MESSAGE); credits = Integer.parseInt(scredits); gpa = Double.parseDouble(sgpa); tuition = Integer.parseInt(stuition); major = Integer.parseInt(smajor); totalgpa=totalgpa+gpa; totaltuition=totaltuition+tuition; totalcredits=totalcredits+credits; if (gpa > largestg) { largestg = gpa; highnameg = last; } if (major == 1) { if (gpa > largestm1) { largestm1 = gpa; highnamem1 = last; } else if (major == 2) { if (gpa > largestm2) { largestm2 = gpa; highnamem2 = last; } } if (credits <= 30) { credits1 = students; } else if (credits >=31 && credits <=60) { credits2 = students; } else if (credits >=61 && credits <=90) { credits3 = students; } else if (credits >=90) { credits4 = students; } } sfinish = JOptionPane.showInputDialog(null, "Enter 0 if your done or 1 to continue", "Input Data", JOptionPane.QUESTION_MESSAGE); finish = Integer.parseInt(sfinish); } //while loop //do calcs and such double agpa = totalgpa / students; double avgtu = totaltuition / students; int avgcr = totalcredits / students; //print out results JOptionPane.showMessageDialog(null, "\nAverage GPA = " + agpa + "\nTuition = $" + totaltuition + "\nAverage tuition = $" + avgtu + "\nAverage credits = $" + avgcr + "\nHighest GPA from " + highnameg +" " +largestg + "\nHighest GPA from a math student is " + highnamem1 +" from " +largestm1+ "\nHighest GPA from a cis student is " + highnamem2 +" from " +largestm2+ "\nNumber of Freshman is " +credits1+ "\nNumber of Sophomore is " +credits2+ "\nNumber of Junior is " +credits3+ "\nNumber of Senior is " +credits4+ JOptionPane.INFORMATION_MESSAGE); } }

any help is appreciated thank you