Practical PapersISCClass 12Computer Science

ISC Practical 2027: Account Number Checksum Verifier – Algorithm and Java Program

Fully solved ISC Computer Science Practical 2027 question: validate a 10-digit account number, apply the double-every-second-digit checksum and find the digital root. Includes the algorithm, a documented Java program, verified outputs and exam tips.

7 min read
ISC Practical 2027: Account Number Checksum Verifier – Algorithm and Java Program

This is Question 1 of Sample Paper 1 from the specimen questions CISCE has released for the ISC Year 2027 Computer Science Practical (Paper 2). The concept area is Number logic. 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 bank performs a few checks on an account number before accepting it. Design a class AccountVerifier to accept one 10-digit account number and perform the following tasks:

  1. Check whether the account number has exactly 10 digits. If not, display INVALID FORMAT and stop.
  2. Starting from the right, double every second digit and leave the other digits unchanged. If a doubled value is greater than 9, subtract 9 from it. Add the resulting digits. If the total is divisible by 10, display Checksum Valid; otherwise display Checksum Invalid.
  3. Add up the original digits of the number. If the result has more than one digit, add its digits again, and repeat until a single digit remains. This final digit is the Digital Root. Display whether the digital root is odd or even.

Worked example from the paper for 4388576018: the doubled digits are 4 → 8, 8 → 16 − 9 = 7, 5 → 10 − 9 = 1, 6 → 12 − 9 = 3 and 1 → 2. Total = 8 + 3 + 7 + 8 + 1 + 7 + 3 + 0 + 2 + 8 = 47, which is not divisible by 10, so the checksum is invalid.

CISCE gives 3 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.

Understanding the problem

This is a number logic question built on the Luhn checksum, the same check used for credit-card numbers. There are three independent jobs: validate the format, compute the checksum, and compute the digital root. Write one method for each and the program almost writes itself.

  • Read the number as a String, not an int. A 10-digit number can be as large as 9999999999, which does not fit in an int (maximum 2147483647). A String also lets you check that every character is a digit and keeps leading zeros.
  • Positions are counted from the right. The rightmost digit is position 1, so positions 2, 4, 6, 8 and 10 are doubled. Loop from the last character to the first and keep a position counter.
  • "Subtract 9" is the same as adding the two digits of the doubled value (16 → 1 + 6 = 7 = 16 − 9). Either way gives the same total.
  • Digital root: keep adding digits while the sum is greater than 9.
Checksum calculation for account number 4388576018 showing every second digit from the right doubled
Question 1: 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 the account number as a String acc.
  3. If the length of acc is not 10, or any character is not a digit, print "INVALID FORMAT" and stop.
  4. Set total = 0 and pos = 1.
  5. For i from the last index down to 0: let d = digit at i. If pos is even, set d = d × 2, and if d > 9 set d = d − 9. Add d to total. Increase pos by 1.
  6. If total % 10 == 0, print "Checksum: Valid", otherwise print "Checksum: Invalid".
  7. Set sum = sum of all digits of acc.
  8. While sum > 9: replace sum by the sum of its own digits.
  9. Print the digital root (sum) followed by "(Root Even)" if sum is even, otherwise "(Root Odd)".
  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.

AccountVerifier.java
import java.util.Scanner;

/**
 * ISC Practical 2027 - Sample Paper 1, Question 1
 * Verifies a 10-digit bank account number using a checksum rule
 * and finds the digital root of the number.
 */
public class AccountVerifier
{
    String acc;          // account number, kept as a String so that all 10 digits are preserved

    AccountVerifier(String a)
    {
        acc = a.trim();
    }

    // true only if acc has exactly 10 characters and every character is a digit
    boolean isValidFormat()
    {
        if (acc.length() != 10)
            return false;
        for (int i = 0; i < acc.length(); i++)
        {
            if (!Character.isDigit(acc.charAt(i)))
                return false;
        }
        return true;
    }

    // starting from the right, doubles every second digit (subtracting 9 if it exceeds 9) and adds all digits
    int checksumTotal()
    {
        int total = 0;
        int pos = 1;                                    // position counted from the right
        for (int i = acc.length() - 1; i >= 0; i--)
        {
            int d = acc.charAt(i) - '0';                // character to digit
            if (pos % 2 == 0)                           // every second digit from the right
            {
                d = d * 2;
                if (d > 9)
                    d = d - 9;
            }
            total += d;
            pos++;
        }
        return total;
    }

    // adds the digits repeatedly until a single digit remains
    int digitalRoot()
    {
        int sum = 0;
        for (int i = 0; i < acc.length(); i++)
            sum += acc.charAt(i) - '0';
        while (sum > 9)
        {
            int s = 0;
            while (sum > 0)
            {
                s += sum % 10;
                sum /= 10;
            }
            sum = s;
        }
        return sum;
    }

    void display()
    {
        System.out.println("Account Number: " + acc);
        if (!isValidFormat())
        {
            System.out.println("INVALID FORMAT");
            return;
        }
        if (checksumTotal() % 10 == 0)
            System.out.println("Checksum      : Valid");
        else
            System.out.println("Checksum      : Invalid");
        int root = digitalRoot();
        System.out.println("Digital Root  : " + root + (root % 2 == 0 ? " (Root Even)" : " (Root Odd)"));
    }

    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        System.out.print("Account Number: ");
        String a = sc.nextLine();
        AccountVerifier ob = new AccountVerifier(a);
        ob.display();
    }
}

Variable description

Variable description
Name           Type       Purpose
-------------  ---------  -------
acc            String     account number entered by the user
total          int        checksum total of the processed digits
pos            int        position of the digit counted from the right
d              int        current digit (doubled when pos is even)
sum            int        running sum used to find the digital root
root           int        final single-digit digital root

Output [3 marks]

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

Example 1
INPUT:
Account Number: 1000000016

OUTPUT:
1000000016
Checksum      : Valid
Digital Root  : 8 (Root Even)
Example 2
INPUT:
Account Number: 4388576018

OUTPUT:
4388576018
Checksum      : Invalid
Digital Root  : 5 (Root Odd)
Example 3
INPUT:
Account Number: 123456789

OUTPUT:
123456789
INVALID FORMAT

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:

Letters inside the number
INPUT:
Account Number: 43885A6018

OUTPUT:
43885A6018
INVALID FORMAT
A random 10-digit number
INPUT:
Account Number: 7992739871

OUTPUT:
7992739871
Checksum      : Invalid
Digital Root  : 8 (Root Even)
All zeros (10 digits)
INPUT:
Account Number: 0000000000

OUTPUT:
0000000000
Checksum      : Valid
Digital Root  : 0 (Root Even)

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
  • State in your algorithm that the number is read as a String and why. Examiners award the "choice of data type" mark for exactly this kind of reasoning.
  • Keep the output format close to the question: label, colon, value. The examiner compares your printout with the expected output.
  • Test a number with letters (43885A6018) and a 9-digit number. These are the unknown inputs an examiner is most likely to try.
  • 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

  • Using int or nextInt(), which crashes with an InputMismatchException for most 10-digit numbers.
  • Doubling every second digit from the left. That is wrong for a 10-digit number: the rightmost digit is never doubled.
  • Stopping the digital root after one addition (50 → 5 works, but 99 → 18 needs a second step → 9).

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.