I'm trying to do my final project for a class and I can't seem to get part of my code to work properly. The first loop only prompts for data the first time through; after that it skips straight into the nested loop. It's supposed to ask for 5 names and 5 scores for each name but I can only input 1 name.
public class StudentAverageTestScore { public static void main(String[] asdf) { Scanner sc = new Scanner(System.in); String[] students = new String[5]; int[][] scores = new int[5][5]; for(int i=0; i<students.length; i++) { out.println("Enter the name of student " + (i+1)); students[i] = sc.nextLine(); for(int j=0; j<scores.length; j++) { out.println("Enter student's score for test " + (j+1)); scores[i][j] = sc.nextInt(); if(scores[i][j]<0 || scores[i][j]>100) { out.println("Enter a valid test score."); j--; } } } } }