Está en la página 1de 4

JOptionPane Lectura e Impresin de numeros

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

package laboratoriouno;
import javax.swing.JOptionPane;
public class Suma {
public static void main(String[] args)
{
int suma;//declarando la variable suma
//ingresando numeros
String primernum=JOptionPane.showInputDialog("ingrese primer entero: ");
String segnumero=JOptionPane.showInputDialog("ingrese segundo entero: ");
//convirtiendo string a enteros:
int numero1=Integer.parseInt(primernum);
int numero2=Integer.parseInt(segnumero);
//calculo de resultados
suma=numero1+numero2;
//texto de salida
JOptionPane.showMessageDialog(null,"la suma de ambos enteros es: "+ suma);
}
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

package laboratorio1b;
import javax.swing.JOptionPane;
public class Continuo
{
public static void main(String[] args)
{
String salida = "";
sigfila:
for ( int fila = 1; fila <= 5; fila++ )
{
salida += "\n";
for ( int columna = 1; columna <= 10; columna++ )
{
if ( columna > fila )
continue sigfila;
salida += "1 ";
}
}
JOptionPane.showMessageDialog( null, salida,"matriz escalonada",JOptionPane.INFORMATION_MESSAGE );
}
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

package javaapplication16;
import javax.swing.JOptionPane;
public class Producto {

//Nombre de la clase

public static void main( String args[] )


{
int x;
//primer numero
int y;
//segundo numero
int z;
//tercer numero
int resultado; //producto de los numeros
String xValor;
String yValor;
String zValor;

//primer numero ingresado


//segundo numero ingresado
//tercer numero ingresado

//Pedimos el ingreso de los numeros


xValor = JOptionPane.showInputDialog( "Ingrese el primer numero" );
yValor = JOptionPane.showInputDialog( "Ingrese el segundo numero" );
zValor = JOptionPane.showInputDialog( "Ingrese el tercer numero" );
//Guardamos los valores
x = Integer.parseInt( xValor );
y = Integer.parseInt( yValor );
z = Integer.parseInt( zValor );
//Hallando el producto
resultado = x * y * z;
//IMPRIMIENDO EL RESULTADO
JOptionPane.showMessageDialog( null, "EL PRODUCTO ES : " + resultado );
System.exit( 0 );
} // fin del metodo main.
} // fin de la clase.

RESULTADO

También podría gustarte