OMR Evaluation

Question :

Teja works as a professor in ANP University. After the exams, he needs to correct the answer
papers of students. First, he prepares the answer key and then he compares the answer key with
the student’s OMR answer paper. Create a Java application and help Prof. Teja to correct the
OMR answer sheets and calculate the marks.

Adhere to the Sample inputs and outputs.

Note :

  • Get the number of questions as input. It must be a positive number, Else print “Invalid Number” and terminate
  • In both the input series – answer key and student answers, Answers must be in between A to E (Case Sensitive and Both inclusive). Otherwise, Print “Invalid Answers” and terminate the program.
  • Compare the answer key and Student answers. Find the equal values in same position of both lists. If there is any equal values then print “Correct answers are “. Else print “All answers are wrong”
  • For the mark calculation, divide the number of the repeated value by number of the answers and multiply the quotient with 100 and print “Mark is ”

Mark = (correct answer count * 100 ) / Total number of questions

Please do not use System.exit(0) to terminate the program

Assumption: Number of questions cannot be zero

Sample Input 1 :

Enter the No of questions
5
Enter the answer key
A
C
E
B
A
Enter the student answers
D
A
E
B
C

Sample Output 1 :

Correct answers are 2
Mark is 40

Explanation: Position 2 and Position 3 have the same value. 2 answers are correct among the 5. To calculate the mark, mark=(2*100)/5=40. The output is “Correct answers are 2” and “Mark is 40”

Sample Input 2 :

Enter the No of questions
4
Enter the answer key
A
C
D
E
Enter the student answers
B
A
C
D

Sample Output 2 :

All answers are wrong
Mark is 0

Sample Input 3 :

Enter the No of questions
7
Enter the answer key
a

Sample Output 3 :

Invalid Answers

Sample Input 4 :

Enter the No of questions
-1

Sample Output 4 :

Invalid Number

Code :

Question:

import java.util.Scanner;
public class arraysquare{
	public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	int i;
	System.out.println("Enter the No of questions");
	int a=sc.nextInt();
	if(a<0)
	{
		System.out.println("Invalid Number");
		return;
	}
	int count=0;
	int mark=0;
	char b[]=new char[a];
	System.out.println("Enter the answer key");
	for (i=0;i<a;i++) {
		b[i] = sc.next().charAt(0);
		if ((b[i] >= 'a' && b[i] <= 'e')||(b[i] > 'E')) {
			System.out.println("Invalid Answers");
			return;
		}
	}
	char c[]=new char[a];
	System.out.println("Enter the student answers");
	for (i=0;i<a;i++)
	{
		c[i]=sc.next().charAt(0);
		if ((c[i] >= 'a' && c[i] <= 'e')||(b[i]>'E')) {
			System.out.println("Invalid Answers");
			return;
		}
	}
	for(i=0;i<a;i++)
	{
		if(b[i]==c[i])
		{
			count++;
		}
	}
	if(count>0)
		System.out.println("Correct answers are "+count);
		mark=(count*100)/a;
	if(count<1)
		System.out.println("All answers are wrong");
		System.out.println("Mark is "+mark);
	}
}

Recommended:

  1. Numerology Name Checking
  2. Java Program of Kids School Example
  3. Java Program of Java – Python Count
  4. Java Program of Hy-Fly Taxi
  5. Java Program for Harima Realtor’s Example

Leave a Comment

Your email address will not be published. Required fields are marked *

x