-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanswerCompare.java
More file actions
108 lines (80 loc) · 3.3 KB
/
answerCompare.java
File metadata and controls
108 lines (80 loc) · 3.3 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
public class answerCompare{
public static char [] key = new char[30];
public static int totalCorrectCount = 0;
public static int answersChecked = 0;
//public static ArrayList<Integer> answerStats = new ArrayList<Integer>();
public static ArrayList<Integer> correctStats = new ArrayList<Integer>();
private int totalCount = 0;
private int [] answerStatsPlacehold = new int [30];
public void setTotalCount(int newTotalCount) {
this.totalCount = newTotalCount;
}
public int getTotalCount() {
return totalCount;
}
public void setAnswerStats(int newAnswerStats[]) {
answerStatsPlacehold = newAnswerStats;
}
public int[] getAnswerStats() {
return answerStatsPlacehold;
}
public static void main(String[] args){
answerCompare answercompare = new answerCompare();
for (int i = 0; i < 30; i++){
key[i] = 'n';
}
//read in key
for (int i = 0; i < key.length; i++){
if (key[i] != 'n'){
answercompare.setTotalCount(answercompare.getTotalCount() + 1);
}
}
int [] answerStats = new int [answercompare.getTotalCount()];
for (int i = 0; i < answerStats.length; i++){
answerStats[i] = 0;
}
//for each student jpg
char [] answer = new char[30];
int correctCount = 0;
for (int i = 0; i < 30; i++){
answer[i] = 'n';
}
//read in answer sheet
/* sample input*/
ArrayList<Character> exKey = new ArrayList<>(Arrays.asList('a', 'd', 'b', 'c', 'c', 'd', 'e', 'b', 'a', 'c', 'd','d','d','a','a','c','e','a','a','e', 'd'));
ArrayList<Character> exAnswer = new ArrayList<>(Arrays.asList('c', 'b', 'e', 'd', 'a', 'a', 'b', 'n', 'e', 'e', 'c', 'd','a','b','b','b','c','c','e','c','a','b'));
for (int i = 0; i < exKey.size(); i++){
key[i] = exKey.get(i);
answer[i] = exAnswer.get(i);
}
for (int i = 0; i < answercompare.getTotalCount(); i++){
if (key[i] != 'n'){
if (answer[i] != 'n' && key[i] == answer[i]) {
correctCount++;
answerStats[i]++;
}
}
}
totalCorrectCount += correctCount;
answersChecked++;
answercompare.setAnswerStats(answerStats);
//results
DecimalFormat df = new DecimalFormat("#.##");
df.setRoundingMode(RoundingMode.CEILING);
Double d = (double) correctCount / answercompare.getTotalCount();
System.out.println("Final score: " + correctCount + "/" + answercompare.getTotalCount());
System.out.println("Accuracy rate: " + df.format(d * 100) + "%");
for (int element: answerStats) {
System.out.println(element);
}
//stats
totalCorrectCount /= answersChecked;
System.out.println("Average score: " + totalCorrectCount + "/" + answercompare.getTotalCount());
d = (double) totalCorrectCount / answercompare.getTotalCount();
System.out.println("Average accuracy: " + df.format(d * 100) + "%");
}
}