martes, 7 de marzo de 2017

Código y ordinograma: Nos piden un número entre 1 y 12 y nos da el mes

PROGRAMA QUE NOS PIDE METER UN NÚMERO ENTERO ENTRE 1 Y 12 Y NOS DÉ EL MES DEL AÑO QUE ES


ORDINOGRAMA

                                                         INICIO
                                                               |
                                                               |
                                                      Declarar A
                                                               |
                                                               |
                                                           Leer A
                                                               |
                                                               |
                                                            A>1
                                                              y  _____S____
                                                           A<12             |
                                                               |              A==1____n___A==2____n_____...
                                                               |                                                    ...hasta A==12                                                                |
                                                               N
                                                               |
                                                          ERROR


CÓDIGO
<!Dado un numero entre 1 y 12, indicar el mes>
<html>
<head>
</head>
<body>
<script language="JavaScript">
  var A;
  A = prompt('Ingrese primer número:','');
  A = parseInt(A);
  if(A>=1 && A<=12){
    if(A==1)
        document.write('Estamos en ENERO');
    else
    if(A==2)
        document.write('Estamos en FEBRERO');
    else
    if(A==3)
        document.write('Estamos en MARZO');
    else
    if(A==4)
        document.write('Estamos en ABRIL');
    else
    if(A==5)
        document.write('Estamos en MAYO');
    else
    if(A==6)
        document.write('Estamos en JUNIO');
    else
    if(A==7)
        document.write('Estamos en JULIO');
    else
    if(A==8)
        document.write('Estamos en AGOSTO');
    else
    if(A==9)
        document.write('Estamos en SEPTIEMBRE');
    else
    if(A==10)
        document.write('Estamos en OCTUBRE');
    else
    if(A==11)
        document.write('Estamos en NOVIEMBRE');
    else
        document.write('Estamos en DICIEMBRE');
    }
    else
        document.write('Error en dato introducido');
</script>
</body>
</html>

No hay comentarios:

Publicar un comentario