
DUDA CON UN EJERCICIO DE ARRAY
Publicado por abel (3 intervenciones) el 16/06/2016 19:49:22
Hola, quisiera saber si alguien me puede ayudar, tengo que hacer un ejercicio donde me dice que ingrese unas notas de unos alumnos en un array, y que el programa me diga cual es la nota maxima y cual es la nota minima, tengo ya todo el codigo hecho pero no se porque a la hora de que me enseñe la nota minima siempre me sale 0...
os dejo el codigo a continuacion aver si alguien me puede ayudar, Gracias!
os dejo el codigo a continuacion aver si alguien me puede ayudar, Gracias!
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
import java.util.Scanner;
public class notas {
public static void main(String[] args) {
Scanner lector=new Scanner(System.in);
String[] nom = {"Albert","Marc","Daniel"};
int [] notas =new int[1];
int max = notas[0];
int min = notas[0];
for(int i=0;i<nom.length;i++){
System.out.println("Introduzca la nota de "+nom[i]+": ");
for(int j=0;j<notas.length;j++){
notas[j]=lector.nextInt();
if(max<notas[j]){
max=notas[j];
}
else if(min>notas[j]){
min=notas[j];
}
}
}
System.out.println("La nota minima es: " +min);
System.out.println("La nota maxima es: " +max);
}
}
Valora esta pregunta


0