- En esta oportunidad crearemos un ejercicio sobre tabla de multiplicar con la sentencia while
import javax.swing.JOptionPane;
public class ejemplo4
{
public static void main(String[] args)
{
String entrada=JOptionPane.showInputDialog (“Ingrese el numero:”);
int num = Integer.parseInt(entrada);
int i;
i=1;
while (i<=12)
{
JOptionPane.showMessageDialog(null,num + ” * ” + i +” = ” + (num * i));
i=i+1;
}
}
}
Tener en cuenta que este ejemplo en java esta diseñado para netbeans-java.
Anuncios