Está en la página 1de 4

JOptionPane Lectura e Impresin de numeros

1 package laboratoriouno;
2
3 import javax.swing.JOptionPane;
4 public class Suma {
5
6 public static void main(String[] args)
7 {
8 int suma;//declarando la variable suma
9 //ingresando numeros
10 String primernum=JOptionPane.showInputDialog("ingrese primer entero: ");
11 String segnumero=JOptionPane.showInputDialog("ingrese segundo entero: ");
12 //convirtiendo string a enteros:
13 int numero1=Integer.parseInt(primernum);
14 int numero2=Integer.parseInt(segnumero);
15 //calculo de resultados
16 suma=numero1+numero2;
17 //texto de salida
18 JOptionPane.showMessageDialog(null,"la suma de ambos enteros es: "+ suma);
19
20 }
21
22 }




1 package laboratorio1b;
2
3 import javax.swing.JOptionPane;
4
5 public class Continuo
6 {
7 public static void main(String[] args)
8 {
9 String salida = "";
10 sigfila:
11 for ( int fila = 1; fila <= 5; fila++ )
12 {
13 salida += "\n";
14 for ( int columna = 1; columna <= 10; columna++ )
15 {
16 if ( columna > fila )
17 continue sigfila;
18 salida += "1 ";
19 }
20 }
21 JOptionPane.showMessageDialog( null, salida,"matriz escalonada",JOptionPane.INFORMATION_MESSAGE );
22 }
23 }




1 package javaapplication16;
2
3 import javax.swing.JOptionPane;
4
5 public class Producto { //Nombre de la clase
6
7 public static void main( String args[] )
8 {
9 int x; //primer numero
10 int y; //segundo numero
11 int z; //tercer numero
12 int resultado; //producto de los numeros
13
14 String xValor; //primer numero ingresado
15 String yValor; //segundo numero ingresado
16 String zValor; //tercer numero ingresado
17
18 //Pedimos el ingreso de los numeros
19 xValor = JOptionPane.showInputDialog( "Ingrese el primer numero" );
20 yValor = JOptionPane.showInputDialog( "Ingrese el segundo numero" );
21 zValor = JOptionPane.showInputDialog( "Ingrese el tercer numero" );
22
23 //Guardamos los valores
24 x = Integer.parseInt( xValor );
25 y = Integer.parseInt( yValor );
26 z = Integer.parseInt( zValor );
27
28 //Hallando el producto
29 resultado = x * y * z;
30
31 //IMPRIMIENDO EL RESULTADO
32 JOptionPane.showMessageDialog( null, "EL PRODUCTO ES : " + resultado );
33 System.exit( 0 );
34 } // fin del metodo main.
35 } // fin de la clase.


RESULTADO

También podría gustarte