SUNDAY, 12 JULY 2026
Guide For School logo Guide For SchoolStudy Guide For Students On Java Programming
Physics | Chemistry | Mathematics
ICSE | ISC | CBSE
Guide For School logo Guide For SchoolICSE and ISC Resources

[Question 2] ISC 2017 Computer Practical Paper Solved – Quiz Result

21 January 2021

ISC 2017 quiz result program solved with algorithm, explanation, Java program and equivalent Python code.

Click here to download the complete ISC 2017 Computer Science Paper 2 (Practical).

Question:

The result of a quiz competition is to be prepared as follows:

The quiz has five questions with four multiple choices (A, B, C, D), with each question carrying 1 mark for the correct answer. Design a program to accept the number of participants N such that N must be greater than 3 and less than 11. Create a double dimensional array of size (Nx5) to store the answers of each participant row-wise.

Calculate the marks for each participant by matching the correct answer stored in a single dimensional array of size 5. Display the scores for each participant and also the participant(s) having the highest score.

Example: If the value of N = 4, then the array would be:

Note: Array entries are line fed (i.e. one entry per line)

Test your program with the sample data and some random data:

Example 1

INPUT : N = 5

Participant 1 D A B C C
Participant 2 A A D C B
Participant 3 B A C D B
Participant 4 D A D C B
Participant 5 B C A D D

Key: B C D A A

OUTPUT : Scores :

Participant 1 D A B C C
Participant 1 = 0
Participant 2 = 1
Participant 3 = 1
Participant 4 = 1
Participant 5 = 2

Highest score: Participant 5

Example 2

INPUT : N = 4

Participant 1 A C C B D
Participant 2 B C A A C
Participant 3 B C B A A
Participant 4 C C D D B

Key: A C D B B

OUTPUT : Scores :

Participant 1 = 3
Participant 2 = 1
Participant 3 = 1
Participant 4 = 3

Highest score:
Participant 1
Participant 4

Example 3

INPUT : N = 12

OUTPUT : INPUT SIZE OUT OF RANGE.

Algorithm:

Step 1: Start.

Step 2: Input the number of participants N.

Step 3: If N is not greater than 3 and less than 11, display INPUT SIZE OUT OF RANGE and stop.

Step 4: Create a two-dimensional array of size N x 5 to store the answers of all participants.

Step 5: Input five answers for each participant.

Step 6: Input the answer key in a one-dimensional array of size 5.

Step 7: Compare each participant's answers with the answer key and count the correct answers.

Step 8: Store and display the score of every participant.

Step 9: Find the maximum score and display all participants who obtained it.

Step 10: Stop.

Explanation:

In this program, every participant answers five multiple-choice questions. Since each participant has the same number of answers, a two-dimensional array is suitable for storing the data. Each row represents one participant and each column represents one question. The answer key is stored separately in a one-dimensional array of five characters. Once both arrays are filled, the score of a participant is calculated by comparing each answer in that participant's row with the corresponding answer in the key.

The program maintains a score array so that each participant's marks can be stored independently. During score calculation, one mark is added whenever an answer matches the key. After all scores are calculated, the program displays the score of every participant and also keeps track of the highest score. There can be more than one highest scorer, so the program runs another loop through the score array and prints every participant whose score is equal to the maximum score. This satisfies the practical question because it handles input validation, score calculation, score display and tie cases for the highest score.

For example, if Participant 1 enters A C C B D and the key is A C D B B, answers 1, 2 and 4 match, so the score becomes 3. The program repeats this comparison for every row of the answer matrix. The maximum score is not decided while taking input; it is found after all scores are known. This is safer because the program can also print multiple highest scorers when there is a tie, as shown in the sample output.

Programming Code:

Java
/**
 * The class QuizResult_ISC2017 inputs the answers of each participant row-wise
 * and calculates the marks for each participant
 * @author : www.guideforschool.com
 * @Program Type : BlueJ Program - Java
 * @Question Year : ISC Practical 2017 Question 2
 */

import java.util.*;
class QuizResult_ISC2017
{
    char A[][],K[];
    int S[],n;
    
    void input()
    {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter number of participants : ");
        n = sc.nextInt();
        if(n<4 || n>10)
        {
            System.out.println("INPUT SIZE OUT OF RANGE");
            System.exit(0);
        }
        A = new char[n][5]; // Array to store the answers of every participants
        K = new char[5]; // Array to store answer key
        S = new int[n]; // Array to store score of every participant
        System.out.println("\n* Enter answer of each participant row-wise in a single line *\n");
        for(int i = 0; i<n; i++)
        {
            System.out.print("Participant "+(i+1)+" : ");
            for(int j=0; j<5; j++)
            {
                A[i][j] = sc.next().charAt(0);
            }
        }
        System.out.print("\nEnter Answer Key : ");
        for(int i = 0; i<5; i++)
        {
            K[i] = sc.next().charAt(0);
        }
    }

    void CalcScore() // Function to calculate score of every participant
    {

        for(int i = 0; i<n; i++)
        {
            S[i] = 0;
            for(int j=0; j<5; j++)
            {
                if(A[i][j] == K[j]) // Checking if Answer of the participants match with the key or not
                {
                    S[i]++;
                }
            }
        }
    }

    void printScore()
    {
        int max = 0;
        System.out.println("\nSCORES : ");
        for(int i = 0; i<n; i++)
        {
            System.out.println("\tParticipant "+(i+1)+" = "+S[i]);
            if(S[i]>max)
            {
                max = S[i]; // Storing the Highest Score
            }
        }
        System.out.println();
        
        System.out.println("\tHighest Score : "+max);
        
        System.out.println("\tHighest Scorers : ");
        for(int i = 0; i<n; i++) // Printing all those participant number who got highest score
        {
            if(S[i] == max)
            {
                System.out.println("\t\t\tParticipant "+(i+1));
            }
        }
    }

    public static void main(String args[])
    {
        QuizResult_ISC2017 ob = new QuizResult_ISC2017();
        ob.input();
        ob.CalcScore();
        ob.printScore();
    }
}

Equivalent Python Program:

Python
n = int(input("Enter number of participants : "))

if n <= 3 or n >= 11:
    print("INPUT SIZE OUT OF RANGE")
else:
    answers = []
    scores = [0] * n

    print("
* Enter answer of each participant row-wise in a single line *
")
    for i in range(n):
        row = input("Participant " + str(i + 1) + " : ").split()
        answers.append(row)

    key = input("
Enter Answer Key : ").split()

    for i in range(n):
        for j in range(5):
            if answers[i][j] == key[j]:
                scores[i] += 1

    print("
SCORES : ")
    highest = 0
    for i in range(n):
        print("	Participant", i + 1, "=", scores[i])
        if scores[i] > highest:
            highest = scores[i]

    print("
	Highest Score :", highest)
    print("	Highest Scorers : ")
    for i in range(n):
        if scores[i] == highest:
            print("			Participant", i + 1)

Output:

Enter number of participants : 4

* Enter answer of each participant row-wise in a single line *

Participant 1 : A C C B D
Participant 2 : B C A A C
Participant 3 : B C B A A
Participant 4 : C C D D B

Enter Answer Key : A C D B B

SCORES : 
	Participant 1 = 3
	Participant 2 = 1
	Participant 3 = 1
	Participant 4 = 3

	Highest Score : 3
	Highest Scorers : 
	Participant 1
	Participant 4

Leave a Reply

Your email address will not be published. Comments are reviewed before appearing publicly.

Send a comment or correction

Study smarter

Everything you need for ICSE and ISC Computer

Programs, revision notes, solved papers and practical guidance—organized for quick study.

Browse all resources →