Practical PapersISCClass 12Computer Science

ISC Practical 2027: College Enrolment Code Validator and Stream Report – Algorithm and Java Program

Fully solved ISC Computer Science Practical 2027 question: validate college enrolment codes made of a stream, year and serial number, give the exact reason for each rejection, auto-correct lowercase streams and prepare a stream-wise report.

7 min read
ISC Practical 2027: College Enrolment Code Validator and Stream Report – Algorithm and Java Program

This is Question 1 of Sample Paper 3 from the specimen questions CISCE has released for the ISC Year 2027 Computer Science Practical (Paper 2). The concept area is Blended concepts: string + number + array. Below you will find the question, a plain-language explanation of the logic, an exam-ready algorithm, a fully documented Java program, the real output for every sample input, and tips for scoring the full 15 marks.

Every program on this page was compiled with JDK 21 and run on CISCE’s sample inputs, plus extra boundary inputs of the kind a visiting examiner will try.

The question

A college admission portal uses an enrolment code for each applicant, in the format 2 uppercase letters + 4-digit year + 3-digit serial number (for example, SC2026045). The first two letters give the stream: SC – Science, CM – Commerce, HM – Humanities. The year can be 2024, 2025 or 2026, and the serial number must be from 001 to 999.

Design a class to accept codes for 5 to 20 applicants (otherwise display INVALID INPUT) and perform the following tasks:

  1. Check each code. Display ACCEPTED if it is valid; otherwise display the reason for rejection: Incorrect length, Invalid stream, Invalid year or Invalid serial number.
  2. If only the stream letters are in lowercase (such as sc2026045), convert them to uppercase. If the rest of the code is valid, display ACCEPTED AFTER AUTO-CORRECTION.
  3. Count the accepted applicants in each stream and display the stream(s) with the highest number of applicants. If there is a tie, display all such streams.

CISCE gives 2 examples with this question. Each one is shown with its output in the Output section below, so you can check your own program against it.

Note on the CISCE sample: CISCE’s document labels this paper "Sample Paper 2" a second time. It is the third sample paper in the set.

Understanding the problem

A string validation question with a counting report. The important design decision is the order of the checks: length, then stream, then year, then serial. Report the first rule that fails. That is how the sample output gives exactly one reason per code.

  • substring() splits the code into its three parts: stream (0, 2), year (2, 6) and serial (6).
  • Auto-correction applies only to an all-lowercase stream (sc, cm, hm). Mixed case such as "Sc" is not mentioned in the question, so treat it as an invalid stream and state this assumption in your algorithm.
  • Serial 000 is invalid (range 001 to 999). Check it with Integer.parseInt(serial) >= 1 after confirming that all three characters are digits.
  • Auto-corrected codes are accepted, so they count in their stream. In Example 1, SC has 2 applicants (SC2026045 and sc2026075).
Enrolment code split into stream, year and serial, with the four checks in order
Question 7: worked example

Algorithm [3 marks]

Write the algorithm in the planning session, in numbered steps like these. It must match your program exactly.

  1. Start.
  2. Input n. If n < 5 or n > 20, print "INVALID INPUT" and stop.
  3. Input n codes into code[]. Set sc = cm = hm = 0.
  4. For each code c: if its length is not 9, the result is "Incorrect length".
  5. Otherwise let stream = first 2 characters. If stream is "sc", "cm" or "hm", convert it to uppercase and set corrected = true. If stream is not SC, CM or HM, the result is "Invalid stream".
  6. Otherwise let year = characters 3 to 6. If they are not all digits or the year is not 2024 to 2026, the result is "Invalid year".
  7. Otherwise let serial = characters 7 to 9. If they are not all digits or the value is 0, the result is "Invalid serial number".
  8. Otherwise increase the counter of the stream, and the result is "Accepted after auto-correction" if corrected, else "Accepted". Print the code and its result.
  9. Print the three counters. Find max of the counters. Print every stream whose counter equals max (or NONE if max is 0).
  10. Stop.

Java program [7 marks]

The program uses a class with separate methods for each task and comments that explain every data member and the special logic. That is what the 2 documentation marks are for.

EnrolmentChecker.java
import java.util.Scanner;

/**
 * ISC Practical 2027 - Sample Paper 3, Question 1
 * Validates college enrolment codes (2 letters + 4-digit year + 3-digit serial)
 * and prepares a stream-wise report.
 */
public class EnrolmentChecker
{
    String code[];               // enrolment codes as entered
    int n;                       // number of applicants
    int sc, cm, hm;              // accepted applicants in Science, Commerce, Humanities

    EnrolmentChecker(int num)
    {
        n = num;
        code = new String[n];
    }

    void accept(Scanner in)
    {
        System.out.println("Enter " + n + " enrolment codes:");
        for (int i = 0; i < n; i++)
            code[i] = in.next().trim();
    }

    boolean allDigits(String s)
    {
        for (int i = 0; i < s.length(); i++)
            if (!Character.isDigit(s.charAt(i)))
                return false;
        return s.length() > 0;
    }

    /*
     * Returns the result for one code:
     * "Accepted", "Accepted after auto-correction" or the reason for rejection.
     * Also updates the stream counters for accepted codes.
     */
    String check(String c)
    {
        if (c.length() != 9)
            return "Incorrect length";
        String stream = c.substring(0, 2);
        boolean corrected = false;
        if (stream.equals("sc") || stream.equals("cm") || stream.equals("hm"))
        {
            stream = stream.toUpperCase();                 // auto-correct lowercase stream letters
            corrected = true;
        }
        if (!stream.equals("SC") && !stream.equals("CM") && !stream.equals("HM"))
            return "Invalid stream";
        String year = c.substring(2, 6);
        if (!allDigits(year))
            return "Invalid year";
        int y = Integer.parseInt(year);
        if (y < 2024 || y > 2026)
            return "Invalid year";
        String serial = c.substring(6);
        if (!allDigits(serial) || Integer.parseInt(serial) < 1)
            return "Invalid serial number";

        if (stream.equals("SC")) sc++;
        else if (stream.equals("CM")) cm++;
        else hm++;
        return corrected ? "Accepted after auto-correction" : "Accepted";
    }

    void report()
    {
        for (int i = 0; i < n; i++)
            System.out.println(code[i] + " : " + check(code[i]));

        System.out.println("Stream Report");
        System.out.println("SC : " + sc);
        System.out.println("CM : " + cm);
        System.out.println("HM : " + hm);
        int max = Math.max(sc, Math.max(cm, hm));
        String top = "";
        if (max > 0)
        {
            if (sc == max) top += "SC ";
            if (cm == max) top += "CM ";
            if (hm == max) top += "HM ";
        }
        System.out.println("Highest Enrollment : " + (max == 0 ? "NONE" : top.trim().replace(" ", ", ")));
    }

    public static void main(String args[])
    {
        Scanner in = new Scanner(System.in);
        System.out.print("Number of applicants: ");
        int n = in.nextInt();
        if (n < 5 || n > 20)
        {
            System.out.println("INVALID INPUT");
            return;
        }
        EnrolmentChecker ob = new EnrolmentChecker(n);
        ob.accept(in);
        ob.report();
    }
}

Variable description

Variable description
Name           Type       Purpose
-------------  ---------  -------
code[]         String[]   enrolment codes as entered
n              int        number of applicants
sc, cm, hm     int        accepted applicants per stream
stream         String     first two characters of a code
year, serial   String     year and serial parts of a code
corrected      boolean    true if the stream was converted from lowercase
max            int        highest stream count

Output [3 marks]

These are the actual outputs of the program above for every example in the question:

Example 1
INPUT:
Number of applicants: 5
SC2026045 CM2025012 sc2026075 AB2025015 HM2025000

OUTPUT:
SC2026045 : Accepted
CM2025012 : Accepted
sc2026075 : Accepted after auto-correction
AB2025015 : Invalid stream
HM2025000 : Invalid serial number
Stream Report
SC : 2
CM : 1
HM : 0
Highest Enrollment : SC
Example 2
INPUT:
Number of applicants: 3

OUTPUT:
INVALID INPUT

Test it on unknown inputs

One of the 3 output marks is for correct output on inputs the examiner chooses, usually boundary cases. Our program handles these correctly:

Every rejection reason and a tie
INPUT:
Number of applicants: 7
SC20260451 Sc2026045 CM2023012 HM2026A12 SC2024999 CM2026001 hm2025010

OUTPUT:
SC20260451 : Incorrect length
Sc2026045 : Invalid stream
CM2023012 : Invalid year
HM2026A12 : Invalid serial number
SC2024999 : Accepted
CM2026001 : Accepted
hm2025010 : Accepted after auto-correction
Stream Report
SC : 1
CM : 1
HM : 1
Highest Enrollment : SC, CM, HM

How to score full marks on this question

Marks distribution for the ISC Computer Science practical: algorithm 3, program 7, hard copy 2, output 3
ISC Paper 2: how the 15 exam marks are divided
  • Write check() as a method that returns the result as a String. One method with early returns mirrors the order of checks, and the examiner can follow it easily.
  • Print the original code (sc2026075), not the corrected one. That matches the sample output.
  • Prepare a test with a tie (for example one accepted code in each stream). The question explicitly asks for ties.
  • Keep the typed program identical to the planned one. Large differences between your planning sheet and the printout cost the 2 hard-copy marks.

Common mistakes to avoid

  • Checking the year with parseInt() before confirming the characters are digits, which crashes on "2O26".
  • Counting rejected codes in the stream report.
  • Accepting serial number 000.

This post is part of our series that solves all 12 specimen questions for the ISC 2027 Computer Science practical, one question a day. Practise writing the algorithm and program on paper in 90 minutes before you type it. That is exactly how the exam works.