0

Im trying to write a program that calculates grades, but I'm having an issue with the while loop: i know finalGrade is unchanged, but I dont know how to fix it. Any help is appreciated!

    protected static void getGrade ( String[] Sections, int[] weights ) {

    Scanner keyboard = new Scanner(System.in);

    int finalGrade = 0;
    int i = 0;
    int score = 0;

    while ( i < Sections.length )
    {   

        System.out.println("Enter all grades for " + Sections[i] );
        String[] grades = keyboard.nextLine().split("\\W+");

        for ( int q = 0; q < grades.length; q++ )
            score += Integer.parseInt( grades[q] );



        score = score / grades.length;
        finalGrade += ( score * ( weights[i] / 100 ) ); 

        score = 0;
        i++;
    }

    System.out.println("your grade is " + finalGrade);
}

0 Answers0