Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public static void main(String[] args) {
Scanner lector = new Scanner(System.in);
String[] letras = {"T", "R", "W", "A", "G", "M", "Y", "F", "P", "D", "X", "B", "N", "J", "Z", "S", "Q", "V", "H", "L", "C", "K", "E"};
int[] valors = new int[5];
int ocupacio = 0, i, x;
int posicion;
do {
System.out.println("Introduce numeros de DNI");
for (i = 0; i < valors.length; i++) {
if (lector.hasNextInt()) {
valors[i] = lector.nextInt();
} else if (lector.hasNext("fi")) {
break;
} else {
System.out.println("Dada Incorrecta");
lector.nextLine();
i--;
}
}
for (x = 0; x < letras.length; x++) {
letras[x] = lector.next();
ocupacio = i;
posicion = x % 23;
for (int j = 0; j < ocupacio; j++) {
System.out.println(valors[j]);
System.out.println("NIF: " + valors[j] + "-"+ letras[posicion]);
}
}
} while (!lector.hasNext("fi"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment