-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path34.1 MCQ paper checker.java
77 lines (55 loc) · 2.07 KB
/
34.1 MCQ paper checker.java
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
/*
Dr. Max has conducted the academic task in his class with 5 Multiple Choice Questions each having 4 options A/B/C/D. He wanted to write a program which can evaluate the test papers of all the N students such that each correct answer is awarded 1 mark and for incorrect answer penalty is 0.25 marks.
The program must read the number of students N and the the answers of all the N students in the form of a String. If any question is not attempted by any student, then X should be given as input corresponding to that question e.g. ABAXD
It is expected that the marks of all the N students are displayed separated by SPACE.
Input Format
First Line of the input reads the String of CORRECT ANSWERS
Second Line of the input reads the number of students N
Next N lines read the answer Strings of the N students respectively.
Constraints
N > 0
Input characters can be either in Upper Case or Lower Case
Output Format
Print the marks of all the N students separated by SPACE
Sample Input 0
ACBDC
2
BCXDX
AXXDC
Sample Output 0
1.75 3.0
Sample Input 1
CCABD
1
aBbxX
Sample Output 1
-0.75
*/
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
//5 mcq , 4 option A/B/C/D, +1 -0.25
Scanner sc = new Scanner(System.in);
String Correct = sc.next();
Correct = Correct.toUpperCase();
int total_student = sc.nextInt();
for(int s=0;s<total_student;s++)
{
String student_ans = sc.next();
student_ans = student_ans.toUpperCase();
double marks = 0;
for(int i=0;i<student_ans.length();i++)
{
if(student_ans.charAt(i)=='X')
continue;
else if(student_ans.charAt(i)==Correct.charAt(i))
marks++;
else
marks -= 0.25;
}
System.out.print(marks + " ");
}
}
}