miércoles, 15 de marzo de 2017

Calcular letra DNI con else if

html>
    <head>
    </head>
    <body>
            <script type="text/javascript">
        var resto;//resto de dividir dnu/23
        var dni; //n asignado al dni
        dni=parseInt(prompt('dame el dni',''));
        resto=dni%23;
        if(resto==0)
        alert(dni+'T');
            else if(resto==1)
            alert(dni+'R');
            else if (resto==2)
            alert(dni+'W');
            else if (resto==3)
            alert(dni+'A');
            else if(resto==4)
            alert(dni+'G');
            else if(resto==5)
            alert(dni+'M');
            else if(resto==6)
            alert(dni+'Y');
            else if(resto==7)
            alert(dni+'F');
            else if(resto==8)
            alert(dni+'P');
            else if(resto==9)
            alert(dni+'D');
            else if(resto==10)
            alert(dni+'X');
            else if(resto==11)
            alert(dni+'B');
            else if(resto==12)
            alert(dni+'N');
            else if(resto==13)
            alert(dni+'J');
            else if(resto==14)
            alert(dni+'Z');
            else if(resto==15)
            alert(dni+'S');
            else if(resto==16)
            alert(dni+'Q');
            else if(resto==17)
            alert(dni+'V');
            else if(resto==18)
            alert(dni+'H');
            else if(resto==19)
            alert(dni+'L');
            else if(resto==20)
            alert(dni+'C');
            else if(resto==21)
            alert(dni+'K');
            else if(resto==22)
            alert (dni+'E');
            </script>
    </body>

</html>

No hay comentarios:

Publicar un comentario