miércoles, 4 de febrero de 2015

Ejercicio 5 Tema 3: Calcular el NIF usando arrays

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package ejercicio5;
import java.util.Scanner;
/**
 *
 * @author juan
 */
public class Ejercicio5 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        char [] 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 numDni;
        int resto;
     
        Scanner leer = new Scanner(System.in);
       
        System.out.println("Introduzca su dni: ");
        numDni= leer.nextInt();
        resto = numDni%23;
       
        System.out.println(letras[resto]);
     
       
       
    }
   
}

No hay comentarios: