package com.vrachieru.cnp4j;

public class CnpUtil {

    public static final int CNP_LENGTH = 13;

    public static final int[] WEIGHTS = new int[]{2, 7, 9, 1, 4, 6, 3, 5, 8, 2, 7, 9};

    public static int calculateCheckDigit(String cnp) {
        int sum = calculateSum(cnp);
        int checkDigit = sum % 11;
        return (checkDigit == 10) ? 1 : checkDigit;
    }

    public static int calculateSum(String cnp) {
        int sum = 0;
        for (int i = 0; i < CNP_LENGTH - 1; i++) {
            sum += Integer.valueOf(cnp.charAt(i)) * WEIGHTS[i];
        }
        return sum;
    }
}

@@ -23,16 +23,68 @@
 cnp4j;%0A%0A
+import static java.lang.Character.getNumericValue;%0A%0A
 public c
@@ -564,23 +564,23 @@
  += 
-Integer.v
+getNumericV
 alue
-Of
 (cnp

Fix char to int convesion