Cambiar Static
Publicado por Juan Perez (1 intervención) el 29/01/2021 02:04:33
Me piden cambiar los static en la declaración del arreglo, en la variable aux y en los metodos.
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import javax.swing.*;
public class Programa1 {
static int edad []= new int [11];
static int aux =0;
static public int [] captura (int ...edad) {
int i=1;
String dato;
while (i<=10) {
dato = JOptionPane.showInputDialog("Digitar Valor" + i);
edad [i] = Integer.parseInt(dato);
i++;
}
return edad;
}
static public int [] ordena (int... edad ) {
for (int i=1; i<=10; i++) {
for (int j=i+1;j<=10;j++) {
if (edad [i]>edad[j]) {
aux = edad[i]; edad [i] = edad [j]; edad [j] = aux;
}
}
}
return edad;
}
static public void imprime (int... edad) {
//for (int a:edad) System.out.println(a);
for (int i=1; i<=10; i++) System.out.println(edad[i]);
}
static public void main (String[] args ) {
edad = captura (edad);
edad = ordena (edad);
imprime (edad);
}
}
Valora esta pregunta


0