Results 1 to 2 of 2
- 11-12-2011, 03:15 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 28
- Rep Power
- 0
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));
}
}
}
- 11-13-2011, 11:25 AM #2
Member
- Join Date
- Oct 2010
- Posts
- 28
- Rep Power
- 0
Similar Threads
-
Checking to see if Array is sorted
By pytho in forum New To JavaReplies: 5Last Post: 07-06-2011, 01:39 AM -
Checking for two strings in array at the same time
By veronique in forum New To JavaReplies: 10Last Post: 04-27-2011, 05:36 AM -
Checking ascending order of array
By counterfox in forum New To JavaReplies: 3Last Post: 10-22-2010, 10:44 PM -
How can I get my array output result onto one dialog box???
By Reero8532 in forum New To JavaReplies: 4Last Post: 03-20-2010, 04:17 AM -
Checking if something is equals to anything in an array
By Sapster in forum New To JavaReplies: 5Last Post: 03-19-2010, 12:26 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks