Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Student grading application

  1. #1
    Member
    Join Date
    Mar 2010
    Posts
    271
    Thanks
    21
    Thanked 7 Times in 7 Posts

    Default Student grading application

    Hello everyone!

    Got an assignment I got to do and i'm completely befuddled. All I got to do is: "Create a program that uses a multidimensional array to store student grades. The first dimension should be a number for each student's grades, and the second dimension should be for each student's grades. Display the average of all the grades earned by each student and an overall average for every student."

    I have no clue how that should be done; all I got atm is student grades.

    class Hr9StudentGrader {
        public static void main(String []args){
            int twodim [][] = new int[6][6];
            twodim[0][0] = 30;
            twodim[0][1] = 26;
            twodim[0][2] = 88;
            twodim[0][3] = 96;
            twodim[0][4] = 72;
            twodim[0][5] = 81;
            twodim[1][0] = 48;
            twodim[1][1] = 36;
            twodim[1][2] = 95;
            twodim[1][3] = 63;
            twodim[1][4] = 100;
            twodim[1][5] = 54;
            twodim[2][0] = 68;
            twodim[2][1] = 49;
            twodim[2][2] = 36;
            twodim[2][3] = 65;
            twodim[2][4] = 65;
            twodim[2][5] = 32;
            twodim[3][0] = 46;
            twodim[3][1] = 56;
            twodim[3][2] = 65;
            twodim[3][3] = 65;
            twodim[3][4] = 46;
            twodim[3][5] = 95;
            twodim[4][0] = 66;
            twodim[4][1] = 46;
            twodim[4][2] = 84;
            twodim[4][3] = 98;
            twodim[4][4] = 46;
            twodim[4][5] = 35;
            twodim[5][0] = 78;
            twodim[5][1] = 69;
            twodim[5][2] = 98;
            twodim[5][3] = 98;
            twodim[5][4] = 82;
            twodim[5][5] = 64;
     
        }
    }
    Last edited by Melawe; May 16th, 2011 at 08:53 PM.


  2. #2
    Member vanDarg's Avatar
    Join Date
    Jan 2011
    Location
    Chicago
    Posts
    65
    My Mood
    Mellow
    Thanks
    1
    Thanked 7 Times in 7 Posts

    Default Re: Student grading application

    I'm sure you know how to calculate average: average = total of scores / number of scores

    To calculate each students grade:
    Loop through each student, keeping track of the total scores. After you iterate through one student, perform the average calculation by dividing that particular student's score by the total number of scores (which will be 6).

    To calculate the total average.
    You can just add up each individual student's average and then divide by the number of students.
    "Everything should be made as simple as possible, but not simpler."
    Asking Questions for Dummies | The Java Tutorials | Java Coding Styling Guide

  3. #3
    Member
    Join Date
    Mar 2010
    Posts
    271
    Thanks
    21
    Thanked 7 Times in 7 Posts

    Default Re: Student grading application

    Thanks for putting it that way!


    class Hr9StudentGrader {
        public static void main(String []args){
            int twodim [][] = new int[6][6];
     
            twodim[0][0] = 30;
            twodim[0][1] = 26;
            twodim[0][2] = 88;
            twodim[0][3] = 96;
            twodim[0][4] = 72;
            twodim[0][5] = 81;
     
            twodim[1][0] = 48;
            twodim[1][1] = 36;
            twodim[1][2] = 95;
            twodim[1][3] = 63;
            twodim[1][4] = 100;
            twodim[1][5] = 54;
     
            twodim[2][0] = 68;
            twodim[2][1] = 49;
            twodim[2][2] = 36;
            twodim[2][3] = 65;
            twodim[2][4] = 65;
            twodim[2][5] = 32;
     
            twodim[3][0] = 46;
            twodim[3][1] = 56;
            twodim[3][2] = 65;
            twodim[3][3] = 65;
            twodim[3][4] = 46;
            twodim[3][5] = 95;
     
            twodim[4][0] = 66;
            twodim[4][1] = 46;
            twodim[4][2] = 84;
            twodim[4][3] = 98;
            twodim[4][4] = 46;
            twodim[4][5] = 35;
     
            twodim[5][0] = 78;
            twodim[5][1] = 69;
            twodim[5][2] = 98;
            twodim[5][3] = 98;
            twodim[5][4] = 82;
            twodim[5][5] = 64;
     
            int SIX = 6;
            int issac = 0;
            int dawiet = 0;
            int alem = 0;
            int ghebremariam = 0;
            int daniel = 0;
            int minus = 0;
     
            for(int index = 0; index < 6; index++){
                issac = issac + twodim[0][index];
            }
            issac = issac / SIX;
            System.out.println("The average grade mark of Issac is: " + issac);
     
            for(int index = 0; index < 6; index++){
                dawiet = dawiet + twodim[1][index];
            }
            dawiet = dawiet / SIX;
            System.out.println("The average grade mark of dawiet is: " + dawiet);
     
            for(int index = 0; index < 6; index++){
                alem = alem + twodim[2][index];
            }
            alem = alem / SIX;
            System.out.println("The average grade mark of alem is: " + alem);
     
            for(int index = 0; index < 6; index++){
                ghebremariam = ghebremariam + twodim[3][index];
            }
            ghebremariam = ghebremariam / SIX;
            System.out.println("The average grade mark of ghebremariam is: " + ghebremariam);
     
            for(int index = 0; index < 6; index++){
                daniel = daniel + twodim[4][index];
            }
            daniel = daniel / SIX;
            System.out.println("The average grade mark of daniel is: " + daniel);
     
            for(int index = 0; index < 6; index++){
                minus = minus + twodim[5][index];
            }
            minus = minus / SIX;
            System.out.println("The average grade mark of minus is: " + minus);
        }
    }
    Output:
    run:
    The average grade mark of Issac is: 65
    The average grade mark of dawiet is: 66
    The average grade mark of alem is: 52
    The average grade mark of ghebremariam is: 62
    The average grade mark of daniel is: 62
    The average grade mark of minus is: 81
    BUILD SUCCESSFUL (total time: 4 seconds)

Similar Threads

  1. Student Programs
    By Suzanne42 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 26th, 2011, 09:20 AM
  2. grading program help
    By devilhanzou in forum What's Wrong With My Code?
    Replies: 6
    Last Post: February 14th, 2011, 08:01 AM
  3. Grading
    By BuhRock in forum Java Theory & Questions
    Replies: 5
    Last Post: April 18th, 2010, 05:05 PM
  4. Student TreeMap
    By raphytaffy in forum Algorithms & Recursion
    Replies: 6
    Last Post: March 1st, 2010, 11:11 PM
  5. [SOLVED] Problem with Grading calculator in java program
    By Peetah05 in forum What's Wrong With My Code?
    Replies: 23
    Last Post: March 28th, 2009, 04:25 PM

Tags for this Thread