Hello guys, I'm trying to make a list of students grade using array. My question is, how am I going to do this?
OUTPUT:
Lea 94
Morgan 85
Jenny 92
Harold 75
I've tried a bit to program, please do check my code.
public class StudentScoreArray {
public static void main(String[] args){
int[] scores = { 94, 85, 92, 75 };
String[] students = { "Lea", "Morgan", "Jenny", "Harold" };
for( int i = 0; i < scores.length; i++ ){
//System.out.print(scores[i] + " ");
for( int j = 0; j < students.length; j++ ){
System.out.print(students[j] + " " + scores[i] + " ");
}
System.out.println("");
}
}
}
But I got this:
Lea 94 Morgan 94 Jenny 94 Harold 94
Lea 85 Morgan 85 Jenny 85 Harold 85
Lea 92 Morgan 92 Jenny 92 Harold 92
Lea 75 Morgan 75 Jenny 75 Harold 75
Any help would be appreciated :)