-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathExamChecking.java
More file actions
35 lines (33 loc) · 1.1 KB
/
ExamChecking.java
File metadata and controls
35 lines (33 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
public class ExamChecking {
public static void main(String[] args) {
char[] stdAnswer = new char [] {'A', 'B', 'C'};
char[] solAnswer = new char[] {'A', 'C', 'C', 'A', 'B'};
System.out.println("TRUE="+examChecking(stdAnswer,solAnswer));
}
public static int examChecking(char[]stdAnswer,char[] solAnswer){
int pointAns=0;
int countQ=solAnswer.length;
int countA=stdAnswer.length;
if(countA==countQ){
for(int i=0;i<countQ;i++){
if(stdAnswer[i]==solAnswer[i]){
pointAns=pointAns+2;
}else{
pointAns--;
}
}
}else{
for(int i=0;i<countA;i++){
if(stdAnswer[i]==solAnswer[i]){
pointAns=pointAns+2;
}else{
pointAns--;
}
}
for(int j=countA;j<countQ;j++){
pointAns--;
}
}
return pointAns;
}
}