imprimir mi método en block de notas
Publicado por hans (3 intervenciones) el 16/07/2019 00:54:55
una ayuda como imprimo el resultado de mis metodos en block de notas???try catch
package ordenamiento;
package ordenamiento;
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
public class Ordenamiento {
public static void muestra(int[]notasx, String[] nombresx){
for(int i=0; i<notasx.length; i++){
System.out.println(notasx[i]+ "\t" +nombresx[i]);
}
}
public static void burbuja(int[]notasx,String[] nombresx){
int i,j,aux_notas;
String aux_nombres;
for( i = 0; i<notasx.length-1; i++){
for (j=i+1;j<notasx.length;j++){
if(notasx[i] > notasx[j])
{
aux_notas = notasx[i];
notasx[i] = notasx[j];
notasx[j] = aux_notas;
aux_nombres = nombresx[i];
nombresx[i] = nombresx[j];
nombresx[j] = aux_nombres;
}
}
}
}
public static void mayor_menor(int notasx[], String []nombresx){
System.out.println("nota mayor:"+ notasx[0]+ "\t" +nombresx[0]);
System.out.println("nota menor:"+ notasx[4]+ "\t" +nombresx[4]);
}
public static void busqueda(int notasx[], String nombresx[]){
for(int i=0; i<nombresx.length; i++){
if(nombresx[i]=="Luis"){
System.out.println("Alumno encontrado: "+notasx[i]+ "\t" +nombresx[i]);
}
}
}
public static void descen(int []notasx,String[] nombresx ){
int i,j,aux_notas;
String aux_nombres;
for( i = 0; i<notasx.length-1; i++){
for (j=i+1;j<notasx.length;j++){
if(notasx[i] < notasx[j])
{
aux_notas = notasx[i];
notasx[i] = notasx[j];
notasx[j] = aux_notas;
aux_nombres = nombresx[i];
nombresx[i] = nombresx[j];
nombresx[j] = aux_nombres;
}
}
}
for(int x=0; x<notasx.length; x++){
System.out.println(notasx[x]+ "\t" +nombresx[x]);
}
}
public static double prom(int[] notasx){
double acu=0,prom;
for(int i=0; i<notasx.length; i++){
acu=acu+notasx[i];
}
prom=(acu)/5;
System.out.println("el promedio general: "+prom);
return prom;
}
public static void main(String[] args) {
int []notas={15,18,16,13,17};
String[] nombres={"Juan", "Pedro", "Luis","María", "Rosa"};
System.out.println("--Arreglo Inicial --");
muestra(notas,nombres);
System.out.println("--Arreglo Ordenado ascendente--");
muestra(notas,nombres);
System.out.println("---Arreglo Ordenado descendente---");
descen(notas,nombres);
prom(notas);
mayor_menor(notas,nombres);
busqueda(notas,nombres);
}
}
Valora esta pregunta


0