Enrolment Report | ISC Computer Science Practical 2027

A college admission portal uses an enrolment code for each applicant. The admission office wants to check these codes and prepare a stream-wise enrolment report.

Each code has the following format:
2 uppercase letters + 4-digit year + 3-digit serial number

Example: SC202645

The first two letters represent 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 and perform the following tasks:
(a) Check each enrolment code. Display ACCEPTED if it is valid; otherwise, display the reason for rejection. The possible reasons for rejection are incorrect length, invalid stream, invalid year, and invalid serial number.
(b) 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.
(c) Count the accepted applicants in each stream. Display the stream(s) with the highest number of applicants. If there is a tie, display all such streams.

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

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 Enrolment: SC

Example 2
INPUT:
Number of applicants: 3
OUTPUT:
INVALID INPUT

import java.util.Scanner;
class Portal{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        System.out.print("Number of applicants: ");
        int n = Integer.parseInt(in.nextLine());
        if(n < 5 || n > 20){
            System.out.println("INVALID INPUT");
            return;
        }
        String a[] = new String[n];
        boolean b[] = new boolean[n];
        System.out.println("Enter the codes: ");
        for(int i = 0; i < a.length; i++)
            a[i] = in.nextLine();
        for(int i = 0; i < a.length; i++){
            if(a[i].length() != 9){
                System.out.println(a[i] + ": INVALID CODE");
                continue;
            }
            String st = a[i].substring(0, 2);
            char first = st.charAt(0);
            char second = st.charAt(1);
            boolean lower = false;
            if(Character.isLowerCase(first) || Character.isLowerCase(second)){
                a[i] = a[i].toUpperCase();
                lower = true;
            }
            if(!a[i].startsWith("SC") && !a[i].startsWith("CM") && !a[i].startsWith("HM")){
                System.out.println(a[i] + ": INVALID STREAM");
                continue;
            }
            int year = Integer.parseInt(a[i].substring(2, 6));
            if(year != 2024 && year != 2025 && year != 2026){
                System.out.println(a[i] + ": INVALID YEAR");
                continue;
            }
            int sno = Integer.parseInt(a[i].substring(6));
            if(sno < 1 || sno > 999){
                System.out.println(a[i] + ": INVALID SERIAL NUMBER");
                continue;
            }
            if(lower){
                System.out.println(a[i] + ": ACCEPTED AFTER AUTO-CORRECTION");
                b[i] = true;
            }
            else{          
                System.out.println(a[i] + ": ACCEPTED");
                b[i] = true;
            }
        }
        int sc = 0;
        int cm = 0;
        int hm = 0;
        for(int i = 0; i < a.length; i++){
            if(a[i].startsWith("SC") && b[i])
                sc++;
            else if(a[i].startsWith("CM") && b[i])
                cm++;
            else if(a[i].startsWith("HM") && b[i])
                hm++;
        }
        System.out.println("STREAM REPORT");
        System.out.println("SC: " + sc);
        System.out.println("CM: " + cm);
        System.out.println("HM: " + hm);
        String highest = "";
        int h = 0;
        if(h < sc)
            h = sc;
        if(h < cm)
            h = cm;
        if(h < hm)
            h = hm;
        if(h == sc)
            highest += "SC ";
        if(h == cm)
            highest += "CM ";
        if(h == hm)
            highest += "HM";
        System.out.println("HIGHEST ENROLLMENT: " + highest);
    }
}