martes, 1 de junio de 2010

CICLO WHILE (PARES)

import javax.swing.JOptionPane;
public class pareswhile
{
public static void main (String args [ ])
{

// DECLARACION DE VARIABLES
int n, i;
String entrada, name;

// ENTRADA DE DATOS
name = JOptionPane.showInputDialog (" Cómo te llamas ?.....");

// CICLO WHILE
String cad="";

i = 2;
while (i <= 30) {
cad= cad + "\n" +i;

i = i + 2;
}

// SALIDA DE DATOS
JOptionPane.showMessageDialog
(null,"LOS NUMEROS PARES SON: \n" + cad);

System.exit(0);
}
}

No hay comentarios:

Publicar un comentario