|
| 1 | +/* |
| 2 | +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. |
| 3 | +
|
| 4 | +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 |
| 5 | +
|
| 6 | +It is expected that the marks of all the N students are displayed separated by SPACE. |
| 7 | +
|
| 8 | +Input Format |
| 9 | +
|
| 10 | +First Line of the input reads the String of CORRECT ANSWERS |
| 11 | +
|
| 12 | +Second Line of the input reads the number of students N |
| 13 | +
|
| 14 | +Next N lines read the answer Strings of the N students respectively. |
| 15 | +
|
| 16 | +Constraints |
| 17 | +
|
| 18 | +N > 0 |
| 19 | +
|
| 20 | +Input characters can be either in Upper Case or Lower Case |
| 21 | +
|
| 22 | +Output Format |
| 23 | +
|
| 24 | +Print the marks of all the N students separated by SPACE |
| 25 | +
|
| 26 | +Sample Input 0 |
| 27 | +
|
| 28 | +ACBDC |
| 29 | +2 |
| 30 | +BCXDX |
| 31 | +AXXDC |
| 32 | +Sample Output 0 |
| 33 | +
|
| 34 | +1.75 3.0 |
| 35 | +Sample Input 1 |
| 36 | +
|
| 37 | +CCABD |
| 38 | +1 |
| 39 | +aBbxX |
| 40 | +Sample Output 1 |
| 41 | +
|
| 42 | +-0.75 |
| 43 | +*/ |
| 44 | + |
| 45 | +import java.io.*; |
| 46 | +import java.util.*; |
| 47 | + |
| 48 | +public class Solution { |
| 49 | + |
| 50 | + public static void main(String[] args) { |
| 51 | + /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ |
| 52 | + //5 mcq , 4 option A/B/C/D, +1 -0.25 |
| 53 | + Scanner sc = new Scanner(System.in); |
| 54 | + String Correct = sc.next(); |
| 55 | + Correct = Correct.toUpperCase(); |
| 56 | + int total_student = sc.nextInt(); |
| 57 | + for(int s=0;s<total_student;s++) |
| 58 | + { |
| 59 | + String student_ans = sc.next(); |
| 60 | + student_ans = student_ans.toUpperCase(); |
| 61 | + double marks = 0; |
| 62 | + for(int i=0;i<student_ans.length();i++) |
| 63 | + { |
| 64 | + if(student_ans.charAt(i)=='X') |
| 65 | + continue; |
| 66 | + else if(student_ans.charAt(i)==Correct.charAt(i)) |
| 67 | + marks++; |
| 68 | + else |
| 69 | + marks -= 0.25; |
| 70 | + } |
| 71 | + System.out.print(marks + " "); |
| 72 | + } |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + } |
| 77 | +} |
0 commit comments