Created
February 13, 2017 17:51
-
-
Save anonymous/c6f8488afc24f7bca1f48e767b662d4b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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