0

I am using an array to store 5 test scores. Then I have another array for the total possible score the test could have. I just need to find out what percent the grade is out of the total possible score.

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        int[] grade = new int[5];
        int[] outOf = new int[5];
        int[] percents = new int[5];
        

        int total = 0;
        int average;
        int percent;

        grade[0] = 70;
        grade[1] = 65;
        grade[2] = 120;
        grade[3] = 150;
        grade[4] = 30;

        outOf[0] = 210;
        outOf[1] = 100;
        outOf[2] = 150;
        outOf[3] = 200;
        outOf[4] = 50;

        for(int i=0;i<grade.length;i++)
        {
            total += grade[i];

        }

        average = total / 5;

        System.out.println("The total is " + total + "\nThe"
                + " average is " + average);
        }
        
        for(int j=0;j<grade.length;j++)
        {
           
            
        }
}
2
Contributors
1
Reply
5
Views
6 Years
Discussion Span
Last Post by Katana24
0

Well to get the average of something you divide by the total number of items and then multiply by 100 to convert to a percentage. You haven't told us what criteria your using to split the grades though.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.