for this code i am getting input on students and their test scores. I’m trying to get all of the scores in my program to print instead of just the last couple of numbers i input. For example, lets say i have 2 students and 2 test and i input the 2 students as Jon, and Tyler, and the tests as
Jon
test1:34
test2:94
Tyler
test1:65
test2:98
instead of printing my input, it prints this:
Jon
test1:65
test2:98
Tyler:
Test 1: 65
Test 2: 98
can anyone help me pinpoint what’s wrong with my code?
static int stuScore; int[][] scores = new int[0][stuScore]; public static void populateTestScores(String[]names,int[][]scores) { for(int stuNames = 0; stuNames < names.length; stuNames++) { System.out.println(); System.out.println("Entering scores for " + names[stuNames] +":" ); for(int testNum=0; testNum<scores[0].length; testNum++) { System.out.print("Enter score for test #" + (testNum+1) + ":" ); scores[testNum][stuScore]= keyboard.nextInt(); } System.out.println(); } } public static void printStudentReport(String[]names,int[][]scores) { System.out.println("Student Report"); System.out.println(); for(int stuNames = 0; stuNames < names.length; stuNames++) { System.out.println("Scores for " + names[stuNames] +":" ); for(int testNum=0; testNum<scores[0].length; testNum++) { System.out.println("Test " + (testNum+1) + ":" +scores[testNum][stuScore]); } System.out.println(); } }