one more question!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tomshorts07
    New Member
    • Apr 2008
    • 9

    one more question!

    hey everyone!

    thanks so much for the help with my grading program that accesses from a file! i just have one more question, basically more of a syntax question

    for those that want to refresh - the original discussion is posted here =
    http://bytes.com/forum/thread794116.ht ml

    what i need to know is, does anyone know how to formulate the code to COMPARE the 'answer key' array to the other arrays with the student answers

    i cant figure out how to syntactically formulate the program to take the answer key array, compare it to the collected other arrays and return a grade

    i was thinking of simply using a method to do the 'grunt work' of the comparison, but if anyone has any better suggestions, they are most certainly welcome!

    thanks so much!
    ~Tomshorts
  • tomshorts07
    New Member
    • Apr 2008
    • 9

    #2
    i almost forgot- for the sake of ease - and maybe to help understand the program a little better, include the code----

    Code:
           public static void main (String[] args)throws IOException {
              
             int x = 0;
             int key[]; //array with the correct answers
             Scanner scan = new Scanner(new File("Grades"));//file with answer key and 'student answers'
             int size = scan.nextInt(); // defines the size of the 'key' array
             Integer Key[] = new Integer[size];
             while (x < size) {
                Key[x] = scan.nextInt();
                x++;
             }         
             
          	
          	
          	// this is where the comparison should take place within the program
          	// possible use of method? 
    
    
             System.out.println ("The Correct answers are...");
             for (int i = 0; i<x; i++)
                System.out.print (Key[i]+" ");
          } 
       }
    thanks everyone!

    Comment

    • Kid Programmer
      New Member
      • Mar 2008
      • 176

      #3
      If I understand the question correctly have the user input the arrays and then compare it using an if (blahblah == blahblah) { blahblah }.

      Comment

      • tomshorts07
        New Member
        • Apr 2008
        • 9

        #4
        thats what i was thinking of using, BUT in order to properly 'grade' the students- it has to return the percentage of the answers that are correct, which means possibly writing possibly hundreds of if () statements,

        if anyone has any idea how to avoid this, im all ears!

        Comment

        • sukatoa
          Contributor
          • Nov 2007
          • 539

          #5
          Originally posted by tomshorts07
          thats what i was thinking of using, BUT in order to properly 'grade' the students- it has to return the percentage of the answers that are correct, which means possibly writing possibly hundreds of if () statements,

          if anyone has any idea how to avoid this, im all ears!
          Please be more specific.....

          How will be the answer compared? not case sensitive?

          If the answer is not complete, should you put some points on it?

          What value should the accepted value be?

          Is the answer more on phrases? or Just a word?Mathematic al solution?Essay?

          What if it is not literally the same but the thought is absolutely the same?

          What's the length of your answer key?

          hundreds of if() statement
          , how about switch?

          regards,
          sukatoa

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #6
            Originally posted by tomshorts07
            thats what i was thinking of using, BUT in order to properly 'grade' the students- it has to return the percentage of the answers that are correct, which means possibly writing possibly hundreds of if () statements,

            if anyone has any idea how to avoid this, im all ears!
            You only need one if statement if you want to count the number of equal elements
            in both arrays:

            [code=java]
            int count(int[] a, int[] b) { // a and b have equal sizes
            int c;
            for (int i= c= 0; i < a.length; i++)
            if (a[i] == b[i]) c++;
            return c;
            }[/code]

            I think you can handle it from there ...

            kind regards,

            Jos

            Comment

            Working...