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 :)

I changed it to

public class StudentScoreArray {
    public static void main(String[] args){

        int[] scores = { 96, 85, 99, 75 };
        String[] students = { "Rizzi", "Ria", "Jho", "Anne" };


            //System.out.print(scores[i] + " ");
        for( int j = 0; j < 4; j++ ){
            for( int i = 0; i < 1; i++ ){
                System.out.print(students[j] + " " + scores[j] + " ");
        }   
        System.out.println("");
        }
    }
}

but i couldn't make it to display each scores.

Hey I already got it.. sorry :p

you can do that with only single string

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.