Skip to content

Instantly share code, notes, and snippets.

Created February 13, 2017 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/c6f8488afc24f7bca1f48e767b662d4b to your computer and use it in GitHub Desktop.
Save anonymous/c6f8488afc24f7bca1f48e767b662d4b to your computer and use it in GitHub Desktop.
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