Java tutorial
//package com.java2s; public class Main { public static String getNif(int number) { String numberStr = String.format("%08d", number); return numberStr + getNifLetter(number); } public static String getNifLetter(int dni) { String nifChars = "TRWAGMYFPDXBNJZSQVHLCKET"; int module = dni % 23; Character nifChar = nifChars.charAt(module); return nifChar.toString(); } }