Results 1 to 2 of 2
  1. #1
    leoshiner is offline Member
    Join Date
    Oct 2010
    Posts
    28
    Rep Power
    0

    Default checking a 2D Array off a 1D Array and outputting result

    Hi I'm trying to create a program which will check students results in a 2D array off of a 1D array answer key
    which will then output each individual students result I have gotten this far but the program is outputting
    incorrect figures and would appreciate any help in resolving this problem,thanks



    char ans[][]= {{'A','B','A','C','C','D','E','E','A','D'},
    {'D','B','A','B','C','A','E','E','A','D'},
    {'E','D','D','A','C','B','E','E','A','D'},
    {'C','B','A','E','D','C','E','E','A','D'},
    {'A','B','D','C','C','D','E','E','A','D'},
    {'B','B','E','C','C','D','E','E','A','D'},
    {'B','B','A','C','C','D','E','E','A','D'},
    {'E','B','E','C','C','D','E','E','A','D'}};





    char key[]={'D','B','D','C','C','D','A','E','A','D'};


    int output=0;
    for (int i=0;i<ans.length;i++){


    for (int j=0;j<ans[i].length;j++){
    if(ans[i][j]==key[i])

    output+=1;



    }
    System.out.println("Student number "+(ans[i])+ "correct count is "+(output));

    }
    }


    }

  2. #2
    leoshiner is offline Member
    Join Date
    Oct 2010
    Posts
    28
    Rep Power
    0

    Default Re: checking a 2D Array off a 1D Array and outputting result

    it's ok I've worked it out

Similar Threads

  1. Checking to see if Array is sorted
    By pytho in forum New To Java
    Replies: 5
    Last Post: 07-06-2011, 01:39 AM
  2. Checking for two strings in array at the same time
    By veronique in forum New To Java
    Replies: 10
    Last Post: 04-27-2011, 05:36 AM
  3. Checking ascending order of array
    By counterfox in forum New To Java
    Replies: 3
    Last Post: 10-22-2010, 10:44 PM
  4. Replies: 4
    Last Post: 03-20-2010, 04:17 AM
  5. Replies: 5
    Last Post: 03-19-2010, 12:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •