Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Lab 1JOptionPane Lectura e Impresion Ejerccio Resuelto
Lab 1JOptionPane Lectura e Impresion Ejerccio Resuelto
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
RESULTADO